Revize 5c67f214
Přidáno uživatelem Pultak před asi 3 roky(ů)
client/usb_detector/usb_reader.py | ||
---|---|---|
1 |
import logging |
|
2 |
|
|
1 | 3 |
import usb.core |
2 | 4 |
import usb.util |
3 | 5 |
|
... | ... | |
10 | 12 |
for bus in busses: |
11 | 13 |
devices = bus.devices |
12 | 14 |
for dev in devices: |
13 |
detected_devices.append({ |
|
14 |
"vendor_id": dev.idVendor, |
|
15 |
"product_id": dev.idProduct |
|
16 |
}) |
|
15 |
try: |
|
16 |
device_info = usb.core.find(idProduct=dev.idProduct) |
|
17 |
detected_devices.append({ |
|
18 |
"vendor_id": dev.idVendor, |
|
19 |
"product_id": dev.idProduct, |
|
20 |
"serial_number": usb.util.get_string(device_info, device_info.iSerialNumber) |
|
21 |
}) |
|
22 |
except: |
|
23 |
logging.warning(f"Failed to retrieve information from device {dev}") |
|
17 | 24 |
|
18 | 25 |
return detected_devices |
Také k dispozici: Unified diff
re #9332 Collected serial number from keyman USB