Skip to content

Commit

Permalink
Merge pull request #39 from sainsaar/ignore_nonexistent_leds_uevent
Browse files Browse the repository at this point in the history
Ignore nonexistent /sys/class/leds/*/device/uevent in find_device_hardware_id
  • Loading branch information
tomoinn committed Aug 11, 2020
2 parents 619c5f7 + f0633b3 commit 68694bf
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/python/approxeng/input/sys.py
Expand Up @@ -102,21 +102,24 @@ def scan_system():
"""

def find_device_hardware_id(uevent_file_path):
hid_uniq = None
phys = None
for line in open(uevent_file_path, 'r').read().split('\n'):
parts = line.split('=')
if len(parts) == 2:
name, value = parts
value = value.replace('"', '')
if name == 'HID_UNIQ' and value:
hid_uniq = value
elif name == 'PHYS' and value:
phys = value.split('/')[0]
if hid_uniq:
return hid_uniq
elif phys:
return phys
try:
hid_uniq = None
phys = None
for line in open(uevent_file_path, 'r').read().split('\n'):
parts = line.split('=')
if len(parts) == 2:
name, value = parts
value = value.replace('"', '')
if name == 'HID_UNIQ' and value:
hid_uniq = value
elif name == 'PHYS' and value:
phys = value.split('/')[0]
if hid_uniq:
return hid_uniq
elif phys:
return phys
except FileNotFoundError:
pass
return None

leds = {}
Expand Down

0 comments on commit 68694bf

Please sign in to comment.