Skip to content

Commit 1c32201

Browse files
authored
Merge 6e4220a into 2214557
2 parents 2214557 + 6e4220a commit 1c32201

3 files changed

Lines changed: 337 additions & 304 deletions

File tree

source/bdDetect.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ def getDriversForConnectedUsbDevices(
141141
)
142142
usbComDeviceMatches = (
143143
DeviceMatch(DeviceType.SERIAL, port["usbID"], port["port"], port)
144-
for port in deviceInfoFetcher.comPorts
145-
if "usbID" in port
144+
for port in deviceInfoFetcher.usbComPorts
146145
)
147146
# Tee is used to ensure that the DeviceMatches aren't created multiple times.
148147
# The processing of these HID device matches, looking for a custom driver, means that all
@@ -256,9 +255,9 @@ def _set_btDevsCache(
256255
self._btDevsCache = cache.copy() if cache else None
257256

258257
#: Type info for auto property: _get_comPorts
259-
comPorts: List[Dict]
258+
comPorts: list[dict[str, str]]
260259

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

264263
#: Type info for auto property: _get_usbDevices
@@ -267,6 +266,21 @@ def _get_comPorts(self) -> List[Dict]:
267266
def _get_usbDevices(self) -> List[Dict]:
268267
return list(hwPortUtils.listUsbDevices(onlyAvailable=True))
269268

269+
#: Type info for auto property: _get_usbComPorts
270+
usbComPorts: list[dict[str, str]]
271+
272+
def _get_usbComPorts(self) -> list[dict[str, str]]:
273+
comPorts = []
274+
for port in self.comPorts:
275+
if (usbId := port.get("usbID")) is None:
276+
continue
277+
if (usbDict := next(
278+
(d for d in self.usbDevices if d.get("usbID") == usbId),
279+
None
280+
)) is not None:
281+
comPorts.append(port | usbDict)
282+
return comPorts
283+
270284
#: Type info for auto property: _get_hidDevices
271285
hidDevices: List[Dict]
272286

@@ -454,7 +468,7 @@ def getConnectedUsbDevicesForDriver(driver: str) -> Iterator[DeviceMatch]:
454468
),
455469
(
456470
DeviceMatch(DeviceType.SERIAL, port["usbID"], port["port"], port)
457-
for port in deviceInfoFetcher.comPorts if "usbID" in port
471+
for port in deviceInfoFetcher.usbComPorts
458472
)
459473
)
460474
for match in usbDevs:

0 commit comments

Comments
 (0)