zeth/inputs

ERROR on import..

Opened this issue · 1 comments

Just the simple act of importing imputs generates this error..

any ideas?

 Traceback (most recent call last):
  File "test.py", line 27, in <module>
    from inputs import devices
  File "/home/koos/.local/lib/python3.6/site-packages/inputs.py", line 3652, in <module>
    devices = DeviceManager()  # pylint: disable=invalid-name

  File "/home/koos/.local/lib/python3.6/site-packages/inputs.py", line 3188, in __init__
    self._post_init()

  File "/home/koos/.local/lib/python3.6/site-packages/inputs.py", line 3197, in _post_init
    self._find_devices()

  File "/home/koos/.local/lib/python3.6/site-packages/inputs.py", line 3346, in _find_devices
    self._find_by('id')

  File "/home/koos/.local/lib/python3.6/site-packages/inputs.py", line 3354, in _find_by
    self._parse_device_path(device_path)

  File "/home/koos/.local/lib/python3.6/site-packages/inputs.py", line 3241, in _parse_device_path
    char_path_override))

  File "/home/koos/.local/lib/python3.6/site-packages/inputs.py", line 2403, in __init__
    self._set_name()

  File "/home/koos/.local/lib/python3.6/site-packages/inputs.py", line 2417, in _set_name
    self.get_char_name()) as name_file:
FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/input/event28/device/name'

The issue is that certain devices where disconnected, but still remained in the /sys/class/input events.

I added a simple try-except clause around iterating devices and it fixed the problem... I will create a pull request.

thanks.