diff options
author | Devaev Maxim <[email protected]> | 2020-05-17 21:30:22 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-05-17 21:30:22 +0300 |
commit | 0447358f5e90b3e81ef56cdaa84042bb16331eb4 (patch) | |
tree | 0a4a6370ba851f15bdf7545c6cf080dd91f0c172 /kvmd/clients | |
parent | 8a13f62911380ee63029d4727b3e9e9df747be1c (diff) |
refactoring
Diffstat (limited to 'kvmd/clients')
-rw-r--r-- | kvmd/clients/kvmd.py | 19 | ||||
-rw-r--r-- | kvmd/clients/streamer.py | 2 |
2 files changed, 6 insertions, 15 deletions
diff --git a/kvmd/clients/kvmd.py b/kvmd/clients/kvmd.py index 1e756ae9..b2667053 100644 --- a/kvmd/clients/kvmd.py +++ b/kvmd/clients/kvmd.py @@ -33,7 +33,7 @@ from .. import make_user_agent # ===== class KvmdError(Exception): def __init__(self, err: Exception): - super().__init__(f"{type(err).__name__} {err}") + super().__init__(f"{type(err).__name__}: {err}") # ===== @@ -57,10 +57,7 @@ class KvmdClient: async def authorize(self, user: str, passwd: str) -> bool: try: async with self.__make_session(user, passwd) as session: - async with session.get( - url=f"http://{self.__host}:{self.__port}/auth/check", - timeout=self.__timeout, - ) as response: + async with session.get(f"http://{self.__host}:{self.__port}/auth/check") as response: response.raise_for_status() if response.status == 200: return True @@ -76,10 +73,7 @@ class KvmdClient: async def ws(self, user: str, passwd: str) -> AsyncGenerator[aiohttp.ClientWebSocketResponse, None]: try: async with self.__make_session(user, passwd) as session: - async with session.ws_connect( - url=f"http://{self.__host}:{self.__port}/ws", - timeout=self.__timeout, - ) as ws: + async with session.ws_connect(f"http://{self.__host}:{self.__port}/ws") as ws: yield ws except aiohttp.ClientError as err: raise KvmdError(err) @@ -89,11 +83,7 @@ class KvmdClient: 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, - }, + params={"quality": quality, "desired_fps": desired_fps}, ) as response: response.raise_for_status() except aiohttp.ClientError as err: @@ -108,6 +98,7 @@ class KvmdClient: "X-KVMD-Passwd": passwd, "User-Agent": make_user_agent("KVMD-VNC"), }, + "timeout": aiohttp.ClientTimeout(total=self.__timeout), } if self.__unix_path: kwargs["connector"] = aiohttp.UnixConnector(path=self.__unix_path) diff --git a/kvmd/clients/streamer.py b/kvmd/clients/streamer.py index 5e068425..e8051855 100644 --- a/kvmd/clients/streamer.py +++ b/kvmd/clients/streamer.py @@ -30,7 +30,7 @@ import aiohttp # ===== class StreamerError(Exception): def __init__(self, err: Exception): - super().__init__(f"{type(err).__name__} {err}") + super().__init__(f"{type(err).__name__}: {err}") # ===== |