diff options
author | Devaev Maxim <[email protected]> | 2020-03-20 15:19:57 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-03-20 15:19:57 +0300 |
commit | 55307fe8da9b483a5d99f459cee5178879f69911 (patch) | |
tree | 1cd8ae773b249184077aa64751ceeaf6301fbc4e /kvmd | |
parent | 8164594b920c6b0c5bc7554621c20165298e3d57 (diff) |
simplified streamer client
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/vnc/kvmd.py | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/kvmd/apps/vnc/kvmd.py b/kvmd/apps/vnc/kvmd.py index d921ad43..5d130b02 100644 --- a/kvmd/apps/vnc/kvmd.py +++ b/kvmd/apps/vnc/kvmd.py @@ -26,8 +26,6 @@ from typing import Dict import aiohttp -from ...logging import get_logger - from ... import __version__ @@ -63,10 +61,7 @@ class KvmdClient: except aiohttp.ClientResponseError as err: if err.status in [401, 403]: return False - get_logger(0).exception("Can't check user access") - except Exception: - get_logger(0).exception("Can't check user access") - return False + raise @contextlib.asynccontextmanager async def ws(self, user: str, passwd: str) -> aiohttp.ClientWebSocketResponse: # pylint: disable=invalid-name @@ -77,23 +72,17 @@ class KvmdClient: ) as ws: yield ws - async def set_streamer_params(self, user: str, passwd: str, quality: int=-1, desired_fps: int=-1) -> None: - params = { - key: value - for (key, value) in [ - ("quality", quality), - ("desired_fps", desired_fps), - ] - if value >= 0 - } - if params: - async with self.__make_session(user, passwd) as session: - async with session.post( - url=f"http://{self.__host}:{self.__port}/streamer/set_params", - timeout=self.__timeout, - params=params, - ) as response: - response.raise_for_status() + async def set_streamer_params(self, user: str, passwd: str, quality: int, desired_fps: int) -> None: + async with self.__make_session(user, passwd) as session: + async with session.post( + url=f"http://{self.__host}:{self.__port}/streamer/set_params", + timeout=self.__timeout, + params={ + "quality": quality, + "desired_fps": desired_fps, + }, + ) as response: + response.raise_for_status() # ===== |