A pure Python implementation of libudev-zero
List all devices
import json
for dev in udev_enumerate_scan_devices():
print(f'Device {dev}: {json.dumps(dev.properties, indent=4)}')
List all USB tty devices
import json
for dev in udev_enumerate_scan_devices(lambda d: d.subsystem == 'tty'):
parent = dev.get_parent_filter(lambda d: d.subsystem == 'usb')
if parent:
print(f'Device {dev}: {json.dumps(dev.properties, indent=4)}')
print(f'Parent {parent}: {json.dumps(parent.properties, indent=4)}')
Udev netlink monitoring is currently not supported.
This library is rewritten from libudev-zero.