refactoring

This commit is contained in:
Maxim Devaev
2022-04-01 02:53:10 +03:00
parent b775239d72
commit 17e140729e
2 changed files with 11 additions and 2 deletions

View File

@@ -32,10 +32,10 @@ from typing import Generator
from ....logging import get_logger from ....logging import get_logger
from .... import env
from .... import tools from .... import tools
from .... import aiomulti from .... import aiomulti
from .... import aioproc from .... import aioproc
from .... import usb
from .events import BaseEvent from .events import BaseEvent
@@ -74,7 +74,7 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in
self.__stop_event = multiprocessing.Event() self.__stop_event = multiprocessing.Event()
def start(self, udc: str) -> None: # type: ignore # pylint: disable=arguments-differ def start(self, udc: str) -> None: # type: ignore # pylint: disable=arguments-differ
self.__udc_state_path = os.path.join(f"{env.SYSFS_PREFIX}/sys/class/udc", udc, "state") self.__udc_state_path = usb.get_udc_path(udc, usb.U_STATE)
super().start() super().start()
def run(self) -> None: # pylint: disable=too-many-branches def run(self) -> None: # pylint: disable=too-many-branches

View File

@@ -38,6 +38,15 @@ def find_udc(udc: str) -> str:
return udc # fe980000.usb return udc # fe980000.usb
# =====
U_STATE = "state"
def get_udc_path(udc: str, *parts: str) -> str:
return os.path.join(f"{env.SYSFS_PREFIX}/sys/class/udc", udc, *parts)
# =====
G_UDC = "UDC" G_UDC = "UDC"
G_FUNCTIONS = "functions" G_FUNCTIONS = "functions"
G_PROFILE_NAME = "c.1" G_PROFILE_NAME = "c.1"