diff options
author | Devaev Maxim <[email protected]> | 2020-05-28 11:03:49 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-05-28 11:03:49 +0300 |
commit | 1c93f6a562d1c2106d148cebb128397989fb84fd (patch) | |
tree | 8065e45b9a07004b5823d8f57a3272796aeb2704 /kvmd/clients | |
parent | fbdfb009a1f752236eeacc8c2528167a64d5d3a8 (diff) |
refactoring
Diffstat (limited to 'kvmd/clients')
-rw-r--r-- | kvmd/clients/kvmd.py | 13 | ||||
-rw-r--r-- | kvmd/clients/streamer.py | 6 |
2 files changed, 10 insertions, 9 deletions
diff --git a/kvmd/clients/kvmd.py b/kvmd/clients/kvmd.py index 70fa7661..e514fb16 100644 --- a/kvmd/clients/kvmd.py +++ b/kvmd/clients/kvmd.py @@ -37,6 +37,7 @@ from typing import Optional import aiohttp from .. import aiotools +from .. import htclient # ===== @@ -56,7 +57,7 @@ class _AuthApiPart(_BaseApiPart): session = self._ensure_http_session() try: async with session.get(self._make_url("auth/check")) as response: - aiotools.raise_not_200(response) + htclient.raise_not_200(response) return True except aiohttp.ClientResponseError as err: if err.status in [401, 403]: @@ -71,14 +72,14 @@ class _StreamerApiPart(_BaseApiPart): url=self._make_url("streamer/set_params"), params={"quality": quality, "desired_fps": desired_fps}, ) as response: - aiotools.raise_not_200(response) + htclient.raise_not_200(response) class _HidApiPart(_BaseApiPart): async def get_keymaps(self) -> Tuple[str, Set[str]]: session = self._ensure_http_session() async with session.get(self._make_url("hid/keymaps")) as response: - aiotools.raise_not_200(response) + htclient.raise_not_200(response) result = (await response.json())["result"] return (result["keymaps"]["default"], set(result["keymaps"]["available"])) @@ -89,14 +90,14 @@ class _HidApiPart(_BaseApiPart): params={"limit": limit, "keymap": keymap_name}, data=text, ) as response: - aiotools.raise_not_200(response) + htclient.raise_not_200(response) class _AtxApiPart(_BaseApiPart): async def get_state(self) -> Dict: session = self._ensure_http_session() async with session.get(self._make_url("atx")) as response: - aiotools.raise_not_200(response) + htclient.raise_not_200(response) return (await response.json())["result"] async def switch_power(self, action: str) -> bool: @@ -106,7 +107,7 @@ class _AtxApiPart(_BaseApiPart): url=self._make_url("atx/power"), params={"action": action}, ) as response: - aiotools.raise_not_200(response) + htclient.raise_not_200(response) return True except aiohttp.ClientResponseError as err: if err.status == 409: diff --git a/kvmd/clients/streamer.py b/kvmd/clients/streamer.py index 7a56556b..493ac080 100644 --- a/kvmd/clients/streamer.py +++ b/kvmd/clients/streamer.py @@ -26,7 +26,7 @@ from typing import AsyncGenerator import aiohttp -from .. import aiotools +from .. import htclient # ===== @@ -59,7 +59,7 @@ class StreamerClient: url=self.__make_url("stream"), params={"extra_headers": "1"}, ) as response: - aiotools.raise_not_200(response) + htclient.raise_not_200(response) reader = aiohttp.MultipartReader.from_response(response) while True: @@ -87,7 +87,7 @@ class StreamerClient: # async def get_snapshot(self) -> Tuple[bool, bytes]: # async with self.__make_http_session(infinite=False) as session: # async with session.get(self.__make_url("snapshot")) as response: -# aiotools.raise_not_200(response) +# htclient.raise_not_200(response) # return ( # (response.headers["X-UStreamer-Online"] == "true"), # bytes(await response.read()), |