diff options
Diffstat (limited to 'kvmd/plugins')
-rw-r--r-- | kvmd/plugins/atx/gpio.py | 5 | ||||
-rw-r--r-- | kvmd/plugins/hid/serial.py | 3 | ||||
-rw-r--r-- | kvmd/plugins/msd/otg/__init__.py | 5 | ||||
-rw-r--r-- | kvmd/plugins/msd/otg/drive.py | 6 | ||||
-rw-r--r-- | kvmd/plugins/msd/relay.py | 3 | ||||
-rw-r--r-- | kvmd/plugins/ugpio/gpio.py | 5 |
6 files changed, 15 insertions, 12 deletions
diff --git a/kvmd/plugins/atx/gpio.py b/kvmd/plugins/atx/gpio.py index 52a52151..b1d6d5d9 100644 --- a/kvmd/plugins/atx/gpio.py +++ b/kvmd/plugins/atx/gpio.py @@ -28,6 +28,7 @@ import gpiod from ...logging import get_logger +from ... import env from ... import aiotools from ... import aiogp @@ -76,7 +77,7 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes self.__reset_switch_line: Optional[gpiod.Line] = None self.__reader = aiogp.AioReader( - path=aiogp.DEVICE_PATH, + path=env.GPIO_DEVICE_PATH, consumer="kvmd::atx-gpio::leds", pins={ power_led_pin: aiogp.AioReaderPinParams(power_led_inverted, power_led_debounce), @@ -107,7 +108,7 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes assert self.__power_switch_line is None assert self.__reset_switch_line is None - self.__chip = gpiod.Chip(aiogp.DEVICE_PATH) + self.__chip = gpiod.Chip(env.GPIO_DEVICE_PATH) self.__power_switch_line = self.__chip.get_line(self.__power_switch_pin) self.__power_switch_line.request("kvmd::atx-gpio::power_switch", gpiod.LINE_REQ_DIR_OUT, default_vals=[0]) diff --git a/kvmd/plugins/hid/serial.py b/kvmd/plugins/hid/serial.py index c7c1164d..13a2db6d 100644 --- a/kvmd/plugins/hid/serial.py +++ b/kvmd/plugins/hid/serial.py @@ -43,6 +43,7 @@ from ...logging import get_logger from ...keyboard.mappings import KEYMAP +from ... import env from ... import aiotools from ... import aiomulti from ... import aioproc @@ -168,7 +169,7 @@ class _Gpio: if self.__reset_pin >= 0: assert self.__chip is None assert self.__reset_line is None - self.__chip = gpiod.Chip(aiogp.DEVICE_PATH) + self.__chip = gpiod.Chip(env.GPIO_DEVICE_PATH) self.__reset_line = self.__chip.get_line(self.__reset_pin) self.__reset_line.request("kvmd::hid-serial::reset", gpiod.LINE_REQ_DIR_OUT, default_vals=[0]) diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py index 2c795970..ef925065 100644 --- a/kvmd/plugins/msd/otg/__init__.py +++ b/kvmd/plugins/msd/otg/__init__.py @@ -44,7 +44,6 @@ from ....yamlconf import Option from ....validators.os import valid_abs_dir from ....validators.os import valid_command -from .... import tools from .... import aiotools from .... import aiofs @@ -139,7 +138,6 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes remount_cmd: List[str], unlock_cmd: List[str], - sysfs_prefix: str, gadget: str, # XXX: Not from options, see /kvmd/apps/kvmd/__init__.py for details ) -> None: @@ -150,7 +148,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes self.__remount_cmd = remount_cmd self.__unlock_cmd = unlock_cmd - self.__drive = Drive(sysfs_prefix, gadget, instance=0, lun=0) + self.__drive = Drive(gadget, instance=0, lun=0) self.__new_file: Optional[aiofiles.base.AiofilesContextManager] = None self.__new_file_written = 0 @@ -170,7 +168,6 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes "storage": Option("/var/lib/kvmd/msd", type=valid_abs_dir, unpack_as="storage_path"), "remount_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-remount", "{mode}"], type=valid_command), "unlock_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-unlock", "unlock"], type=valid_command), - "sysfs_prefix": Option("", type=tools.str_strip), } async def get_state(self) -> Dict: diff --git a/kvmd/plugins/msd/otg/drive.py b/kvmd/plugins/msd/otg/drive.py index ff91afcf..a0a0d82b 100644 --- a/kvmd/plugins/msd/otg/drive.py +++ b/kvmd/plugins/msd/otg/drive.py @@ -23,6 +23,8 @@ import os import errno +from .... import env + from .. import MsdOperationError @@ -34,9 +36,9 @@ class MsdDriveLockedError(MsdOperationError): # ===== class Drive: - def __init__(self, prefix: str, gadget: str, instance: int, lun: int) -> None: + def __init__(self, gadget: str, instance: int, lun: int) -> None: self.__path = os.path.join( - f"{prefix}/sys/kernel/config/usb_gadget", + f"{env.SYSFS_PREFIX}/sys/kernel/config/usb_gadget", gadget, f"functions/mass_storage.usb{instance}/lun.{lun}", ) diff --git a/kvmd/plugins/msd/relay.py b/kvmd/plugins/msd/relay.py index d1d91841..fe1c7784 100644 --- a/kvmd/plugins/msd/relay.py +++ b/kvmd/plugins/msd/relay.py @@ -39,6 +39,7 @@ import gpiod from ...logging import get_logger +from ... import env from ... import aiotools from ... import aiofs from ... import aiogp @@ -172,7 +173,7 @@ class _Gpio: assert self.__target_line is None assert self.__reset_line is None - self.__chip = gpiod.Chip(aiogp.DEVICE_PATH) + self.__chip = gpiod.Chip(env.GPIO_DEVICE_PATH) self.__target_line = self.__chip.get_line(self.__target_pin) self.__target_line.request("kvmd::msd-relay::target", gpiod.LINE_REQ_DIR_OUT, default_vals=[0]) diff --git a/kvmd/plugins/ugpio/gpio.py b/kvmd/plugins/ugpio/gpio.py index 7c3f317c..4d50d4fc 100644 --- a/kvmd/plugins/ugpio/gpio.py +++ b/kvmd/plugins/ugpio/gpio.py @@ -25,6 +25,7 @@ from typing import Optional import gpiod +from ... import env from ... import aiotools from ... import aiogp @@ -58,13 +59,13 @@ class Plugin(BaseUserGpioDriver): def prepare(self) -> None: assert self.__reader is None self.__reader = aiogp.AioReader( - path=aiogp.DEVICE_PATH, + path=env.GPIO_DEVICE_PATH, consumer="kvmd::ugpio-gpio::inputs", pins=self.__input_pins, notifier=self._notifier, ) - self.__chip = gpiod.Chip(aiogp.DEVICE_PATH) + self.__chip = gpiod.Chip(env.GPIO_DEVICE_PATH) for (pin, initial) in self.__output_pins.items(): line = self.__chip.get_line(pin) line.request("kvmd::ugpio-gpio::outputs", gpiod.LINE_REQ_DIR_OUT, default_vals=[int(initial or False)]) |