From 5f5754e860e0829355f565ee477629ba48872b4f Mon Sep 17 00:00:00 2001 From: Richard P Date: Wed, 29 May 2024 20:33:15 +0100 Subject: [PATCH] Add Exception handling when processing udev devices (#5088) * Add Exception handling to UDEV reading and parsing Khadas VIM4 UDEV returns something that python crapps its pants about. The exception just allows it to continue. * Add an exception print Added an exception print for the times things go bad. * Split exception handling The exception is not fatal when parsing error happens on one node. print it and continue. * cleanups * swapped functions device.device_node function bails very badly! It raises no exceptions to the top but complains and errors * Update supervisor/hardware/manager.py Co-authored-by: Stefan Agner * Update supervisor/hardware/manager.py --------- Co-authored-by: Stefan Agner Co-authored-by: Pascal Vizeli --- supervisor/hardware/manager.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/supervisor/hardware/manager.py b/supervisor/hardware/manager.py index 30dc44b6f8b..6c154d45e3d 100644 --- a/supervisor/hardware/manager.py +++ b/supervisor/hardware/manager.py @@ -103,7 +103,13 @@ def _import_devices(self) -> None: # Exctract all devices for device in self._udev.list_devices(): # Skip devices without mapping - if not device.device_node or self.helper.hide_virtual_device(device): + try: + if not device.device_node or self.helper.hide_virtual_device(device): + continue + except UnicodeDecodeError as err: + # Some udev properties have an unkown/different encoding. This is a general + # problem with pyudev, see https://github.com/pyudev/pyudev/pull/230 + _LOGGER.warning("Ignoring udev device due to error: %s", err) continue self._devices[device.sys_name] = Device.import_udev(device)