mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-15 21:26:29 +00:00
Cleanup udev handling (#1137)
* Cleanup udev handling * Update hardware.py
This commit is contained in:
parent
5771b417bc
commit
6d6deb8c66
@ -36,17 +36,14 @@ class Hardware:
|
|||||||
"""Return all serial and connected devices."""
|
"""Return all serial and connected devices."""
|
||||||
dev_list = set()
|
dev_list = set()
|
||||||
for device in self.context.list_devices(subsystem="tty"):
|
for device in self.context.list_devices(subsystem="tty"):
|
||||||
if "ID_VENDOR" in device or RE_TTY.search(device.device_node):
|
if "ID_VENDOR" in device.properties or RE_TTY.search(device.device_node):
|
||||||
dev_list.add(device.device_node)
|
dev_list.add(device.device_node)
|
||||||
|
|
||||||
# Add /dev/serial/by-id devlink for current device
|
# Add /dev/serial/by-id devlink for current device
|
||||||
if "DEVLINKS" in device and device["DEVLINKS"]:
|
for dev_link in device.device_links:
|
||||||
devlinks = [
|
if not dev_link.startswith("/dev/serial/by-id"):
|
||||||
symlink
|
continue
|
||||||
for symlink in device["DEVLINKS"].split(" ")
|
dev_list.add(dev_link)
|
||||||
if symlink.startswith("/dev/serial/by-id")
|
|
||||||
]
|
|
||||||
dev_list.update(devlinks)
|
|
||||||
|
|
||||||
return dev_list
|
return dev_list
|
||||||
|
|
||||||
@ -55,8 +52,8 @@ class Hardware:
|
|||||||
"""Return all input devices."""
|
"""Return all input devices."""
|
||||||
dev_list = set()
|
dev_list = set()
|
||||||
for device in self.context.list_devices(subsystem="input"):
|
for device in self.context.list_devices(subsystem="input"):
|
||||||
if "NAME" in device:
|
if "NAME" in device.properties:
|
||||||
dev_list.add(device["NAME"].replace('"', ""))
|
dev_list.add(device.properties["NAME"].replace('"', ""))
|
||||||
|
|
||||||
return dev_list
|
return dev_list
|
||||||
|
|
||||||
@ -65,7 +62,7 @@ class Hardware:
|
|||||||
"""Return all disk devices."""
|
"""Return all disk devices."""
|
||||||
dev_list = set()
|
dev_list = set()
|
||||||
for device in self.context.list_devices(subsystem="block"):
|
for device in self.context.list_devices(subsystem="block"):
|
||||||
if device.device_node.startswith("/dev/sd"):
|
if "ID_NAME" in device.properties:
|
||||||
dev_list.add(device.device_node)
|
dev_list.add(device.device_node)
|
||||||
|
|
||||||
return dev_list
|
return dev_list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user