sysinfo.py 1.9 KB

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