Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions source/bdDetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ def getDriversForConnectedUsbDevices(
)
usbComDeviceMatches = (
DeviceMatch(KEY_SERIAL, port["usbID"], port["port"], port)
for port in deviceInfoFetcher.comPorts
if "usbID" in port
for port in deviceInfoFetcher.usbComPorts
)
# Tee is used to ensure that the DeviceMatches aren't created multiple times.
# The processing of these HID device matches, looking for a custom driver, means that all
Expand Down Expand Up @@ -234,9 +233,9 @@ def _set_btDevsCache(
self._btDevsCache = cache.copy() if cache else None

#: Type info for auto property: _get_comPorts
comPorts: List[Dict]
comPorts: list[dict[str, str]]

def _get_comPorts(self) -> List[Dict]:
def _get_comPorts(self) -> list[dict[str, str]]:
return list(hwPortUtils.listComPorts(onlyAvailable=True))

#: Type info for auto property: _get_usbDevices
Expand All @@ -245,6 +244,21 @@ def _get_comPorts(self) -> List[Dict]:
def _get_usbDevices(self) -> List[Dict]:
return list(hwPortUtils.listUsbDevices(onlyAvailable=True))

#: Type info for auto property: _get_usbComPorts
usbComPorts: list[dict[str, str]]

def _get_usbComPorts(self) -> list[dict[str, str]]:
comPorts = []
for port in self.comPorts:
if (usbId := port.get("usbID")) is None:
continue
if (usbDict := next(
(d for d in self.usbDevices if d.get("usbID") == usbId),
None
)) is not None:
comPorts.append(port | usbDict)
return comPorts

#: Type info for auto property: _get_hidDevices
hidDevices: List[Dict]

Expand Down Expand Up @@ -432,7 +446,7 @@ def getConnectedUsbDevicesForDriver(driver: str) -> Iterator[DeviceMatch]:
),
(
DeviceMatch(KEY_SERIAL, port["usbID"], port["port"], port)
for port in deviceInfoFetcher.comPorts if "usbID" in port
for port in deviceInfoFetcher.usbComPorts
)
)
for match in usbDevs:
Expand Down
Loading