diff options
author | Maxim Devaev <[email protected]> | 2022-04-06 00:39:16 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-04-06 00:55:20 +0300 |
commit | 6f6772a6b62ecaaa166197f097f82d81c6fb9422 (patch) | |
tree | b0e1a2d8e316e8e7abe9b51f702ac7d8d27aedfa | |
parent | 8ce08fb4567ed7f3cfad85da4ae1e123eef42024 (diff) |
refactoring
-rw-r--r-- | kvmd/apps/kvmd/api/atx.py | 6 | ||||
-rw-r--r-- | kvmd/apps/kvmd/api/auth.py | 14 | ||||
-rw-r--r-- | kvmd/apps/kvmd/api/export.py | 4 | ||||
-rw-r--r-- | kvmd/apps/kvmd/api/hid.py | 14 | ||||
-rw-r--r-- | kvmd/apps/kvmd/api/info.py | 6 | ||||
-rw-r--r-- | kvmd/apps/kvmd/api/log.py | 6 | ||||
-rw-r--r-- | kvmd/apps/kvmd/api/msd.py | 14 | ||||
-rw-r--r-- | kvmd/apps/kvmd/api/redfish.py | 8 | ||||
-rw-r--r-- | kvmd/apps/kvmd/api/streamer.py | 8 | ||||
-rw-r--r-- | kvmd/apps/kvmd/api/ugpio.py | 6 | ||||
-rw-r--r-- | kvmd/apps/kvmd/auth.py | 4 | ||||
-rw-r--r-- | kvmd/apps/kvmd/server.py | 27 | ||||
-rw-r--r-- | kvmd/apps/kvmd/snapshoter.py | 4 | ||||
-rw-r--r-- | kvmd/apps/kvmd/ugpio.py | 10 | ||||
-rw-r--r-- | kvmd/htserver.py (renamed from kvmd/apps/kvmd/http.py) | 2 | ||||
-rw-r--r-- | kvmd/plugins/msd/__init__.py | 4 |
16 files changed, 68 insertions, 69 deletions
diff --git a/kvmd/apps/kvmd/api/atx.py b/kvmd/apps/kvmd/api/atx.py index 9107b9c6..68ce0479 100644 --- a/kvmd/apps/kvmd/api/atx.py +++ b/kvmd/apps/kvmd/api/atx.py @@ -23,15 +23,15 @@ from aiohttp.web import Request from aiohttp.web import Response +from ....htserver import exposed_http +from ....htserver import make_json_response + from ....plugins.atx import BaseAtx from ....validators.basic import valid_bool from ....validators.kvm import valid_atx_power_action from ....validators.kvm import valid_atx_button -from ..http import exposed_http -from ..http import make_json_response - # ===== class AtxApi: diff --git a/kvmd/apps/kvmd/api/auth.py b/kvmd/apps/kvmd/api/auth.py index 36604b2e..590f1411 100644 --- a/kvmd/apps/kvmd/api/auth.py +++ b/kvmd/apps/kvmd/api/auth.py @@ -25,17 +25,17 @@ import base64 from aiohttp.web import Request from aiohttp.web import Response +from ....htserver import UnauthorizedError +from ....htserver import ForbiddenError +from ....htserver import HttpExposed +from ....htserver import exposed_http +from ....htserver import make_json_response +from ....htserver import set_request_auth_info + from ....validators.auth import valid_user from ....validators.auth import valid_passwd from ....validators.auth import valid_auth_token -from ..http import UnauthorizedError -from ..http import ForbiddenError -from ..http import HttpExposed -from ..http import exposed_http -from ..http import make_json_response -from ..http import set_request_auth_info - from ..auth import AuthManager diff --git a/kvmd/apps/kvmd/api/export.py b/kvmd/apps/kvmd/api/export.py index 91031056..ca367f30 100644 --- a/kvmd/apps/kvmd/api/export.py +++ b/kvmd/apps/kvmd/api/export.py @@ -30,14 +30,14 @@ from aiohttp.web import Response from .... import tools +from ....htserver import exposed_http + from ....plugins.atx import BaseAtx from ....plugins.ugpio import UserGpioModes from ..info import InfoManager from ..ugpio import UserGpio -from ..http import exposed_http - # ===== class ExportApi: diff --git a/kvmd/apps/kvmd/api/hid.py b/kvmd/apps/kvmd/api/hid.py index 7f344e43..ddbaadd8 100644 --- a/kvmd/apps/kvmd/api/hid.py +++ b/kvmd/apps/kvmd/api/hid.py @@ -36,6 +36,13 @@ from aiohttp.web import WebSocketResponse from ....mouse import MouseRange +from ....keyboard.keysym import build_symmap +from ....keyboard.printer import text_to_web_keys + +from ....htserver import exposed_http +from ....htserver import exposed_ws +from ....htserver import make_json_response + from ....plugins.hid import BaseHid from ....validators import raise_error @@ -49,13 +56,6 @@ from ....validators.hid import valid_hid_mouse_move from ....validators.hid import valid_hid_mouse_button from ....validators.hid import valid_hid_mouse_delta -from ....keyboard.keysym import build_symmap -from ....keyboard.printer import text_to_web_keys - -from ..http import exposed_http -from ..http import exposed_ws -from ..http import make_json_response - # ===== class HidApi: diff --git a/kvmd/apps/kvmd/api/info.py b/kvmd/apps/kvmd/api/info.py index 55876a1f..bb7caf79 100644 --- a/kvmd/apps/kvmd/api/info.py +++ b/kvmd/apps/kvmd/api/info.py @@ -27,13 +27,13 @@ from typing import List from aiohttp.web import Request from aiohttp.web import Response +from ....htserver import exposed_http +from ....htserver import make_json_response + from ....validators.kvm import valid_info_fields from ..info import InfoManager -from ..http import exposed_http -from ..http import make_json_response - # ===== class InfoApi: diff --git a/kvmd/apps/kvmd/api/log.py b/kvmd/apps/kvmd/api/log.py index b6e67296..dd95aa4f 100644 --- a/kvmd/apps/kvmd/api/log.py +++ b/kvmd/apps/kvmd/api/log.py @@ -23,14 +23,14 @@ from aiohttp.web import Request from aiohttp.web import StreamResponse +from ....htserver import exposed_http +from ....htserver import start_streaming + from ....validators.basic import valid_bool from ....validators.kvm import valid_log_seek from ..logreader import LogReader -from ..http import exposed_http -from ..http import start_streaming - # ===== class LogApi: diff --git a/kvmd/apps/kvmd/api/msd.py b/kvmd/apps/kvmd/api/msd.py index 8b1769b5..75852dd7 100644 --- a/kvmd/apps/kvmd/api/msd.py +++ b/kvmd/apps/kvmd/api/msd.py @@ -36,6 +36,13 @@ from ....logging import get_logger from .... import htclient +from ....htserver import exposed_http +from ....htserver import make_json_response +from ....htserver import make_json_exception +from ....htserver import start_streaming +from ....htserver import stream_json +from ....htserver import stream_json_exception + from ....plugins.msd import BaseMsd from ....validators.basic import valid_bool @@ -44,13 +51,6 @@ from ....validators.basic import valid_float_f01 from ....validators.net import valid_url from ....validators.kvm import valid_msd_image_name -from ..http import exposed_http -from ..http import make_json_response -from ..http import make_json_exception -from ..http import start_streaming -from ..http import stream_json -from ..http import stream_json_exception - # ====== class MsdApi: diff --git a/kvmd/apps/kvmd/api/redfish.py b/kvmd/apps/kvmd/api/redfish.py index 5afd5110..c740ca55 100644 --- a/kvmd/apps/kvmd/api/redfish.py +++ b/kvmd/apps/kvmd/api/redfish.py @@ -25,6 +25,10 @@ import asyncio from aiohttp.web import Request from aiohttp.web import Response +from ....htserver import HttpError +from ....htserver import exposed_http +from ....htserver import make_json_response + from ....plugins.atx import BaseAtx from ....validators import ValidatorError @@ -32,10 +36,6 @@ from ....validators import check_string_in_list from ..info import InfoManager -from ..http import HttpError -from ..http import exposed_http -from ..http import make_json_response - # ===== class RedfishApi: diff --git a/kvmd/apps/kvmd/api/streamer.py b/kvmd/apps/kvmd/api/streamer.py index a2cf961d..0cadb141 100644 --- a/kvmd/apps/kvmd/api/streamer.py +++ b/kvmd/apps/kvmd/api/streamer.py @@ -26,6 +26,10 @@ from typing import Dict from aiohttp.web import Request from aiohttp.web import Response +from ....htserver import UnavailableError +from ....htserver import exposed_http +from ....htserver import make_json_response + from ....validators import check_string_in_list from ....validators.basic import valid_bool from ....validators.basic import valid_number @@ -33,10 +37,6 @@ from ....validators.basic import valid_int_f0 from ....validators.basic import valid_string_list from ....validators.kvm import valid_stream_quality -from ..http import UnavailableError -from ..http import exposed_http -from ..http import make_json_response - from ..streamer import Streamer from ..tesseract import TesseractOcr diff --git a/kvmd/apps/kvmd/api/ugpio.py b/kvmd/apps/kvmd/api/ugpio.py index d5d127cc..b41fba73 100644 --- a/kvmd/apps/kvmd/api/ugpio.py +++ b/kvmd/apps/kvmd/api/ugpio.py @@ -23,15 +23,15 @@ from aiohttp.web import Request from aiohttp.web import Response +from ....htserver import exposed_http +from ....htserver import make_json_response + from ....validators.basic import valid_bool from ....validators.basic import valid_float_f0 from ....validators.ugpio import valid_ugpio_channel from ..ugpio import UserGpio -from ..http import exposed_http -from ..http import make_json_response - # ===== class UserGpioApi: diff --git a/kvmd/apps/kvmd/auth.py b/kvmd/apps/kvmd/auth.py index b9933181..8bd2286d 100644 --- a/kvmd/apps/kvmd/auth.py +++ b/kvmd/apps/kvmd/auth.py @@ -28,11 +28,11 @@ from typing import Optional from ...logging import get_logger +from ... import aiotools + from ...plugins.auth import BaseAuthService from ...plugins.auth import get_auth_service_class -from ... import aiotools - # ===== class AuthManager: diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py index a69cff00..f33412d9 100644 --- a/kvmd/apps/kvmd/server.py +++ b/kvmd/apps/kvmd/server.py @@ -45,8 +45,20 @@ from ...logging import get_logger from ...errors import OperationError from ...errors import IsBusyError -from ...plugins import BasePlugin +from ... import aiotools +from ... import aioproc +from ...htserver import HttpError +from ...htserver import HttpExposed +from ...htserver import exposed_http +from ...htserver import exposed_ws +from ...htserver import get_exposed_http +from ...htserver import get_exposed_ws +from ...htserver import make_json_response +from ...htserver import make_json_exception +from ...htserver import HttpServer + +from ...plugins import BasePlugin from ...plugins.hid import BaseHid from ...plugins.atx import BaseAtx from ...plugins.msd import BaseMsd @@ -59,9 +71,6 @@ from ...validators.kvm import valid_stream_resolution from ...validators.kvm import valid_stream_h264_bitrate from ...validators.kvm import valid_stream_h264_gop -from ... import aiotools -from ... import aioproc - from .auth import AuthManager from .info import InfoManager from .logreader import LogReader @@ -70,16 +79,6 @@ from .streamer import Streamer from .snapshoter import Snapshoter from .tesseract import TesseractOcr -from .http import HttpError -from .http import HttpExposed -from .http import exposed_http -from .http import exposed_ws -from .http import get_exposed_http -from .http import get_exposed_ws -from .http import make_json_response -from .http import make_json_exception -from .http import HttpServer - from .api.auth import AuthApi from .api.auth import check_request_auth diff --git a/kvmd/apps/kvmd/snapshoter.py b/kvmd/apps/kvmd/snapshoter.py index 380984af..65c59eaa 100644 --- a/kvmd/apps/kvmd/snapshoter.py +++ b/kvmd/apps/kvmd/snapshoter.py @@ -27,10 +27,10 @@ from typing import Callable from ...logging import get_logger -from ...plugins.hid import BaseHid - from ... import aiotools +from ...plugins.hid import BaseHid + from .streamer import Streamer diff --git a/kvmd/apps/kvmd/ugpio.py b/kvmd/apps/kvmd/ugpio.py index 458710dc..de69cacf 100644 --- a/kvmd/apps/kvmd/ugpio.py +++ b/kvmd/apps/kvmd/ugpio.py @@ -31,6 +31,11 @@ from typing import Any from ...logging import get_logger +from ...errors import IsBusyError + +from ... import tools +from ... import aiotools + from ...plugins.ugpio import GpioError from ...plugins.ugpio import GpioOperationError from ...plugins.ugpio import GpioDriverOfflineError @@ -38,13 +43,8 @@ from ...plugins.ugpio import UserGpioModes from ...plugins.ugpio import BaseUserGpioDriver from ...plugins.ugpio import get_ugpio_driver_class -from ... import tools -from ... import aiotools - from ...yamlconf import Section -from ...errors import IsBusyError - # ===== class GpioChannelNotFoundError(GpioOperationError): diff --git a/kvmd/apps/kvmd/http.py b/kvmd/htserver.py index a057caed..f1b51b38 100644 --- a/kvmd/apps/kvmd/http.py +++ b/kvmd/htserver.py @@ -45,7 +45,7 @@ try: except ImportError: from aiohttp.helpers import AccessLogger # type: ignore -from ...logging import get_logger +from .logging import get_logger # ===== diff --git a/kvmd/plugins/msd/__init__.py b/kvmd/plugins/msd/__init__.py index 42a5ac0b..31095f3c 100644 --- a/kvmd/plugins/msd/__init__.py +++ b/kvmd/plugins/msd/__init__.py @@ -33,11 +33,11 @@ import aiofiles.base from ...logging import get_logger -from ... import aiofs - from ...errors import OperationError from ...errors import IsBusyError +from ... import aiofs + from .. import BasePlugin from .. import get_plugin_class |