Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore nonexistent /sys/class/leds/*/device/uevent in find_device_hardware_id #39

Merged
merged 1 commit into from Aug 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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