mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 15:43:02 +02:00
yager: handle usb info though the HOST api
Prior to this commit yanger looked at the running system using os.path..., this meant that the static reply / capture data wasn't used properly. This resulted in strange behavior during unit testing on GitHub runners where USB ports are missing. Signed-off-by: Richard Alpe <richard@bit42.se>
This commit is contained in:
@@ -61,18 +61,16 @@ def usb_port_components(systemjson):
|
||||
|
||||
path = usb_port["path"]
|
||||
if os.path.basename(path) == "authorized_default":
|
||||
# TODO: Untestable. Should be done via the host API
|
||||
if os.path.exists(path):
|
||||
with open(path, "r") as f:
|
||||
names.append(usb_port["name"])
|
||||
data = int(f.readline().strip())
|
||||
enabled = "unlocked" if data == 1 else "locked"
|
||||
port["state"] = {}
|
||||
port["state"]["admin-state"] = enabled
|
||||
port["name"] = usb_port["name"]
|
||||
port["class"] = "infix-hardware:usb"
|
||||
port["state"]["oper-state"] = "enabled"
|
||||
ports.append(port)
|
||||
if HOST.exists(path):
|
||||
names.append(usb_port["name"])
|
||||
data = int(HOST.read(path))
|
||||
enabled = "unlocked" if data == 1 else "locked"
|
||||
port["state"] = {}
|
||||
port["state"]["admin-state"] = enabled
|
||||
port["name"] = usb_port["name"]
|
||||
port["class"] = "infix-hardware:usb"
|
||||
port["state"]["oper-state"] = "enabled"
|
||||
ports.append(port)
|
||||
|
||||
return ports
|
||||
|
||||
|
||||
Reference in New Issue
Block a user