Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion monitorcontrol/vcp/vcp_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,20 @@ def get_vcps() -> List[LinuxVCP]:

# iterate I2C devices
for device in pyudev.Context().list_devices(subsystem="i2c"):
vcp = LinuxVCP(device.sys_number)
try:
if sys_no := device.sys_number:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if sys_no := device.sys_number:
if (sys_no := device.sys_number) is None:

I think 0 is a valid device.sys_number.

vcp = LinuxVCP(int(sys_no))
else:
logging.error(
"Unable to check i2c device %s: no device number found", device
)
continue
Comment on lines +396 to +400
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious, have you seen this occur? pyudev should only return None if the device number is not a unicode string: https://github.com/pyudev/pyudev/blob/7588bc8c84bf1e994b31020452124bc6618625ce/src/pyudev/device/_device.py#L626-L651

with vcp:
pass
except (OSError, VCPIOError):
pass
except VCPPermissionError as exc:
logging.error("Unable to check i2c device: %s", exc)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logging.error("Unable to check i2c device: %s", exc)
logging.exception("Unable to check i2c device")

This adds native exception info into the logging record.

else:
vcps.append(vcp)

Expand Down