From 17412be3fead0e24290f5f704e964d3787e6a889 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Thu, 31 Mar 2022 04:44:03 +0300 Subject: [PATCH] get rid of otgbind's cleanup and fixed hid for this --- kvmd/plugins/hid/otg/device.py | 18 +++++++++++------- kvmd/plugins/ugpio/otgbind.py | 4 ---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kvmd/plugins/hid/otg/device.py b/kvmd/plugins/hid/otg/device.py index 6a02d5e8..e76b7294 100644 --- a/kvmd/plugins/hid/otg/device.py +++ b/kvmd/plugins/hid/otg/device.py @@ -228,13 +228,17 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in logger = get_logger() if self.__fd < 0: - try: - flags = os.O_NONBLOCK - flags |= (os.O_RDWR if self.__read_size else os.O_WRONLY) - self.__fd = os.open(self.__device_path, flags) - except Exception as err: - logger.error("Can't open HID-%s device %s: %s", - self.__name, self.__device_path, tools.efmt(err)) + if os.path.exists(self.__device_path): + try: + flags = os.O_NONBLOCK + flags |= (os.O_RDWR if self.__read_size else os.O_WRONLY) + self.__fd = os.open(self.__device_path, flags) + except Exception as err: + logger.error("Can't open HID-%s device %s: %s", + self.__name, self.__device_path, tools.efmt(err)) + time.sleep(1) + else: + time.sleep(1) if self.__fd >= 0: try: diff --git a/kvmd/plugins/ugpio/otgbind.py b/kvmd/plugins/ugpio/otgbind.py index 43fc32fe..17da02a8 100644 --- a/kvmd/plugins/ugpio/otgbind.py +++ b/kvmd/plugins/ugpio/otgbind.py @@ -92,10 +92,6 @@ class Plugin(BaseUserGpioDriver): except Exception: logger.exception("Unexpected OTG-bind watcher error") - async def cleanup(self) -> None: - with open(self.__ctl_path) as ctl_file: - ctl_file.write(self.__udc) - async def read(self, pin: str) -> bool: _ = pin with open(self.__ctl_path) as ctl_file: