diff options
author | Devaev Maxim <[email protected]> | 2021-01-23 07:00:49 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2021-01-23 07:00:49 +0300 |
commit | 4d4fb69d2eb2e9b3d677b82098d888bd899c8c33 (patch) | |
tree | c193f2a0db5fb34f5f58bd96d6ccd771177b1753 /kvmd/plugins/hid/otg | |
parent | ebe40697a5935d5d35a36d0825715ca8c3824c6a (diff) |
refactoring
Diffstat (limited to 'kvmd/plugins/hid/otg')
-rw-r--r-- | kvmd/plugins/hid/otg/device.py | 16 | ||||
-rw-r--r-- | kvmd/plugins/hid/otg/usb.py | 3 |
2 files changed, 7 insertions, 12 deletions
diff --git a/kvmd/plugins/hid/otg/device.py b/kvmd/plugins/hid/otg/device.py index 7757efe8..958f0d4d 100644 --- a/kvmd/plugins/hid/otg/device.py +++ b/kvmd/plugins/hid/otg/device.py @@ -167,8 +167,7 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in err.errno == errno.EAGAIN # pylint: disable=no-member or err.errno == errno.ESHUTDOWN # pylint: disable=no-member ): - logger.debug("HID-%s busy/unplugged (write): %s: %s", - self.__name, type(err).__name__, err) + logger.debug("HID-%s busy/unplugged (write): %s", self.__name, tools.efmt(err)) else: logger.exception("Can't write report to HID-%s", self.__name) @@ -193,7 +192,7 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in try: read = bool(select.select([self.__fd], [], [], 0)[0]) except Exception as err: - logger.error("Can't select() for read HID-%s: %s: %s", self.__name, type(err).__name__, err) + logger.error("Can't select() for read HID-%s: %s", self.__name, tools.efmt(err)) break if read: @@ -201,8 +200,7 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in report = os.read(self.__fd, self.__read_size) except Exception as err: if isinstance(err, OSError) and err.errno == errno.EAGAIN: # pylint: disable=no-member - logger.debug("HID-%s busy/unplugged (read): %s: %s", - self.__name, type(err).__name__, err) + logger.debug("HID-%s busy/unplugged (read): %s", self.__name, tools.efmt(err)) else: logger.exception("Can't read report from HID-%s", self.__name) else: @@ -220,12 +218,8 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in 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 FileNotFoundError: - logger.error("Missing HID-%s device: %s", self.__name, self.__device_path) - time.sleep(self.__reopen_delay) except Exception as err: - logger.error("Can't open HID-%s device: %s: %s: %s", - self.__name, self.__device_path, type(err).__name__, err) + logger.error("Can't open HID-%s device %s: %s", self.__name, self.__device_path, tools.efmt(err)) time.sleep(self.__reopen_delay) else: time.sleep(self.__reopen_delay) @@ -238,7 +232,7 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in else: logger.debug("HID-%s is busy/unplugged (write select)", self.__name) except Exception as err: - logger.error("Can't select() for write HID-%s: %s: %s", self.__name, type(err).__name__, err) + logger.error("Can't select() for write HID-%s: %s", self.__name, tools.efmt(err)) self.__close_device() self.__state_flags.update(online=False) diff --git a/kvmd/plugins/hid/otg/usb.py b/kvmd/plugins/hid/otg/usb.py index 17979003..e4615669 100644 --- a/kvmd/plugins/hid/otg/usb.py +++ b/kvmd/plugins/hid/otg/usb.py @@ -25,6 +25,7 @@ import os from ....logging import get_logger from .... import env +from .... import tools # ===== @@ -47,7 +48,7 @@ class UsbDeviceController: try: candidates = sorted(os.listdir(path)) except Exception as err: - logger.error("Can't list %s: %s: %s: ignored", path, type(err).__name__, err) + logger.error("Can't list %s: %s: ignored", path, tools.efmt(err)) return udc = "" |