Skip to content

Commit

Permalink
Add Exception handling when processing udev devices (#5088)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update supervisor/hardware/manager.py

---------

Co-authored-by: Stefan Agner <[email protected]>
Co-authored-by: Pascal Vizeli <[email protected]>
  • Loading branch information
3 people authored May 29, 2024
1 parent 974c882 commit 5f5754e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion supervisor/hardware/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 5f5754e

Please sign in to comment.