diff options
Diffstat (limited to 'kvmd/plugins/atx')
-rw-r--r-- | kvmd/plugins/atx/__init__.py | 8 | ||||
-rw-r--r-- | kvmd/plugins/atx/disabled.py | 5 | ||||
-rw-r--r-- | kvmd/plugins/atx/gpio.py | 16 |
3 files changed, 12 insertions, 17 deletions
diff --git a/kvmd/plugins/atx/__init__.py b/kvmd/plugins/atx/__init__.py index f7e85057..4ac183c5 100644 --- a/kvmd/plugins/atx/__init__.py +++ b/kvmd/plugins/atx/__init__.py @@ -20,9 +20,7 @@ # ========================================================================== # -from typing import Dict from typing import AsyncGenerator -from typing import Type from ...errors import OperationError from ...errors import IsBusyError @@ -47,10 +45,10 @@ class AtxIsBusyError(IsBusyError, AtxError): # ===== class BaseAtx(BasePlugin): - async def get_state(self) -> Dict: + async def get_state(self) -> dict: raise NotImplementedError - async def poll_state(self) -> AsyncGenerator[Dict, None]: + async def poll_state(self) -> AsyncGenerator[dict, None]: yield {} raise NotImplementedError @@ -84,5 +82,5 @@ class BaseAtx(BasePlugin): # ===== -def get_atx_class(name: str) -> Type[BaseAtx]: +def get_atx_class(name: str) -> type[BaseAtx]: return get_plugin_class("atx", name) # type: ignore diff --git a/kvmd/plugins/atx/disabled.py b/kvmd/plugins/atx/disabled.py index 4f09cba4..9bfb28b2 100644 --- a/kvmd/plugins/atx/disabled.py +++ b/kvmd/plugins/atx/disabled.py @@ -20,7 +20,6 @@ # ========================================================================== # -from typing import Dict from typing import AsyncGenerator from ... import aiotools @@ -37,7 +36,7 @@ class AtxDisabledError(AtxOperationError): # ===== class Plugin(BaseAtx): - async def get_state(self) -> Dict: + async def get_state(self) -> dict: return { "enabled": False, "busy": False, @@ -47,7 +46,7 @@ class Plugin(BaseAtx): }, } - async def poll_state(self) -> AsyncGenerator[Dict, None]: + async def poll_state(self) -> AsyncGenerator[dict, None]: while True: yield (await self.get_state()) await aiotools.wait_infinite() diff --git a/kvmd/plugins/atx/gpio.py b/kvmd/plugins/atx/gpio.py index 8d41e53d..e7089481 100644 --- a/kvmd/plugins/atx/gpio.py +++ b/kvmd/plugins/atx/gpio.py @@ -20,9 +20,7 @@ # ========================================================================== # -from typing import Dict from typing import AsyncGenerator -from typing import Optional import gpiod @@ -76,9 +74,9 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes self.__notifier = aiotools.AioNotifier() self.__region = aiotools.AioExclusiveRegion(AtxIsBusyError, self.__notifier) - self.__chip: Optional[gpiod.Chip] = None - self.__power_switch_line: Optional[gpiod.Line] = None - self.__reset_switch_line: Optional[gpiod.Line] = None + self.__chip: (gpiod.Chip | None) = None + self.__power_switch_line: (gpiod.Line | None) = None + self.__reset_switch_line: (gpiod.Line | None) = None self.__reader = aiogp.AioReader( path=self.__device_path, @@ -91,7 +89,7 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes ) @classmethod - def get_plugin_options(cls) -> Dict: + def get_plugin_options(cls) -> dict: return { "device": Option("/dev/gpiochip0", type=valid_abs_path, unpack_as="device_path"), @@ -122,7 +120,7 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes self.__reset_switch_line = self.__chip.get_line(self.__reset_switch_pin) self.__reset_switch_line.request("kvmd::atx::reset_switch", gpiod.LINE_REQ_DIR_OUT, default_vals=[0]) - async def get_state(self) -> Dict: + async def get_state(self) -> dict: return { "enabled": True, "busy": self.__region.is_busy(), @@ -132,8 +130,8 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes }, } - async def poll_state(self) -> AsyncGenerator[Dict, None]: - prev_state: Dict = {} + async def poll_state(self) -> AsyncGenerator[dict, None]: + prev_state: dict = {} while True: state = await self.get_state() if state != prev_state: |