usb logging on topology change (#38495)

speedup usb detection
This commit is contained in:
Daniel Koepping
2026-07-30 08:26:02 -07:00
committed by GitHub
parent 1c54ff853a
commit caee482fe7
2 changed files with 16 additions and 3 deletions
+8
View File
@@ -1,3 +1,4 @@
import os
from pathlib import Path
CHESTNUT_VENDOR_ID = 0xADD1
@@ -5,6 +6,13 @@ CHESTNUT_PRODUCT_ID = 0x0001
USB_DEVICES_PATH = Path("/sys/bus/usb/devices")
def get_usb_topology() -> set[str]:
try:
return set(os.listdir(USB_DEVICES_PATH))
except OSError:
return set()
def read(path: Path) -> str | None:
try:
return path.read_text().strip()