A pure Python implementation of libudev-zero
List all devices
importjsonfordevinudev_enumerate_scan_devices():
print(f'Device {dev}: {json.dumps(dev.properties, indent=4)}')List all USB tty devices
importjsonfordevinudev_enumerate_scan_devices(lambdad: d.subsystem=='tty'):
parent=dev.get_parent_filter(lambdad: d.subsystem=='usb')
ifparent:
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.