Python evdev exercise: listing accessible devices - Ask Ubuntu
16.04 installed evdev module, goal: reproduce example in screenshot:
screenshot of attempts:
the 'indentationerror' error signals corrective action? can done reproduce list of devices on 16.04 instance? if able reproduce exercise on box, please indicate in response.
evdev install confirmation:
>>> import evdev >>> device = evdev.inputdevice('/dev/input/event0') >>> print(device) device /dev/input/event0, name "logitech m325", phys "usb-3f980000.usb-1.3:1"
update: rinzwind has nudged subject-matter in right direction (no 'indentationerror'):
>>> devices = [evdev.inputdevice(fn) fn in evdev.list_devices()] >>> import evdev >>> devices = [evdev.inputdevice(fn) fn in evdev.list_devices()] >>> device in devices: ... print(device.fn, device.name, device.phys) ... print(device.fn, device.name, device.phys) ...
wondering if observation relevant troubleshooting:
>>> import evdev >>> devices = [evdev.inputdevice(fn) fn in evdev.list_devices()] >>> device in devices: ... print(device.fn, device.name, device.phys) ... >>> device = evdev.inputdevice('/dev/input/event3') traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/local/lib/python2.7/dist-packages/evdev/device.py", line 129, in __init__ fd = os.open(dev, os.o_rdonly | os.o_nonblock) oserror: [errno 13] permission denied: '/dev/input/event3'
where:
cat /proc/bus/input/devices i: bus=0011 vendor=0001 product=0001 version=ab41 n: name="at translated set 2 keyboard" p: phys=isa0060/serio0/input0 s: sysfs=/devices/platform/i8042/serio0/input/input3
continuing seek suggestions , guidance.
python has mandatory indentation.
after line "for" must indent (4 spaces or tab). add them before "print". spaces there in 1st image ;)
Comments
Post a Comment