mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-30 17:41:54 +08:00
refactoring
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user