Debian Codegraph @

scripts/misc/sysinfo.py

raw symbols SCIP
1 import platform, sys
2 import serial.tools.list_ports
3
4 # MacOS Catalina:
5 # platform.system == "Darwin"
6 # Attrs: device, manufacturer, product, vid, pid, location, serial_number
7 #
8 # Ubuntu 18.04:
9 # platform.system == "Linux"
10 # Attrs: device, manufacturer, product, vid, pid, location, serial_number
11 #
12 # Windows 7:
13 # platform.system, platform.release == "Windows", "7"
14 # Attrs: device, vid, pid, location, serial_number
15 # (manufacturer == "InterBiometrics")
16 #
17 # Windows 10:
18 # platform.system, platform.release == "Windows", "10"
19 # Attrs: device, vid, pid, location, serial_number
20 # (manufacturer == "Microsoft")
21
22 print("platform.system: %s" % platform.system())
23 print("platform.version: %s" % platform.version())
24 print("platform.release: %s" % platform.release())
25
26 ports = serial.tools.list_ports.comports()
27 i = 0
28 for port in ports:
29 i += 1
30 print("Port %d:" % i)
31 if port.device:
32 print(" device: '%s'" % port.device)
33 if port.name:
34 print(" name: '%s'" % port.name)
35 if port.hwid:
36 print(" hwid: '%s'" % port.hwid)
37 if port.manufacturer:
38 print(" manufacturer: '%s'" % port.manufacturer)
39 if port.product:
40 print(" product: '%s'" % port.product)
41 if port.vid:
42 print(" vid: %04x" % port.vid)
43 if port.pid:
44 print(" pid: %04x" % port.pid)
45 if port.location:
46 print(" location: '%s'" % port.location)
47 if port.serial_number:
48 print(" serial_number: '%s'" % port.serial_number)
49 if port.interface:
50 print(" interface: '%s'" % port.interface)
51
52 if len(sys.argv) < 2 or sys.argv[1] != "loop":
53 sys.exit(0)
54
55 # Loop checking that .location is always valid for a Weazle
56 while True:
57 for port in serial.tools.list_ports.comports():
58 if port.vid == 0x1209:
59 if not port.location:
60 print("BAD", flush=True)
61 else:
62 print(".", end="", flush=True)
63