refactoring

This commit is contained in:
Devaev Maxim
2020-05-28 11:03:49 +03:00
parent fbdfb009a1
commit 1c93f6a562
9 changed files with 63 additions and 42 deletions

View File

@@ -25,7 +25,7 @@ from typing import Optional
from ...clients.kvmd import KvmdClient
from ... import make_user_agent
from ... import htclient
from .. import init
@@ -45,7 +45,7 @@ def main(argv: Optional[List[str]]=None) -> None:
IpmiServer(
auth_manager=IpmiAuthManager(**config.auth._unpack()),
kvmd=KvmdClient(
user_agent=make_user_agent("KVMD-IPMI"),
user_agent=htclient.make_user_agent("KVMD-IPMI"),
**config.kvmd._unpack(),
),
**config.server._unpack(),

View File

@@ -36,10 +36,9 @@ import aiohttp
from ...logging import get_logger
from ... import aiotools
from ... import htclient
from ... import gpio
from ... import make_user_agent
# =====
class Streamer: # pylint: disable=too-many-instance-attributes
@@ -182,7 +181,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
session = self.__ensure_http_session()
try:
async with session.get(self.__make_url("state")) as response:
aiotools.raise_not_200(response)
htclient.raise_not_200(response)
state = (await response.json())["result"]
except (aiohttp.ClientConnectionError, aiohttp.ServerConnectionError):
pass
@@ -245,7 +244,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
def __ensure_http_session(self) -> aiohttp.ClientSession:
if not self.__http_session:
kwargs: Dict = {
"headers": {"User-Agent": make_user_agent("KVMD")},
"headers": {"User-Agent": htclient.make_user_agent("KVMD")},
"timeout": aiohttp.ClientTimeout(total=self.__timeout),
}
if self.__unix_path:

View File

@@ -26,7 +26,7 @@ from typing import Optional
from ...clients.kvmd import KvmdClient
from ...clients.streamer import StreamerClient
from ... import make_user_agent
from ... import htclient
from .. import init
@@ -42,7 +42,7 @@ def main(argv: Optional[List[str]]=None) -> None:
argv=argv,
)[2].vnc
user_agent = make_user_agent("KVMD-VNC")
user_agent = htclient.make_user_agent("KVMD-VNC")
# pylint: disable=protected-access
VncServer(