From cccf44655aadc80d2d535033951e7af9ac65a271 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Sat, 3 Oct 2020 03:34:55 +0300 Subject: common env variables --- kvmd/plugins/msd/otg/__init__.py | 5 +---- kvmd/plugins/msd/otg/drive.py | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'kvmd/plugins/msd/otg') 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}", ) -- cgit v1.2.3