pyudev

How to monitor usb devices insertion?

How to monitor usb devices insertion? Question: I am trying to monitor for USB devices when they get plugged in. A couple of test scripts fail that I am pretty sure should have worked. import pyudev context = pyudev.Context() monitor = pyudev.Monitor.from_netlink(context) monitor.filter_by(subsystem=’usb’) for device in iter(monitor.poll, None): if device.action == ‘add’: print(‘{} connected’.format(device)) ^^Does …

Total answers: 2