sample_python_hwdata.py 878 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #! /usr/bin/env python3
  2. from hwdata import PCI, PNP, USB
  3. # Test PCI IDs
  4. pci_vendor_id = '1af4'
  5. pci_device_id = '1003'
  6. pci = PCI()
  7. pci_vendor = pci.get_vendor(pci_vendor_id)
  8. print("PCI Vendor: %s" % pci_vendor)
  9. assert (pci_vendor == "Red Hat, Inc.")
  10. pci_device = pci.get_device(pci_vendor_id, pci_device_id)
  11. print("PCI Device: %s" % pci_device)
  12. assert (pci_device == "Virtio console")
  13. # Test USB IDs
  14. usb_vendor_id = '1d6b'
  15. usb_device_id = '0001'
  16. usb = USB()
  17. usb_vendor = usb.get_vendor(usb_vendor_id)
  18. print("USB Vendor: %s" % usb_vendor)
  19. assert (usb_vendor == "Linux Foundation")
  20. usb_device = usb.get_device(usb_vendor_id, usb_device_id)
  21. print("USB Device: %s" % usb_device)
  22. assert (usb_device == "1.1 root hub")
  23. # Test PNP IDs
  24. pnp_id = 'RHT'
  25. pnp = PNP()
  26. pnp_vendor = pnp.get_vendor(pnp_id)
  27. print("PNP Vendor: %s" % pnp_vendor)
  28. assert (pnp_vendor == "Red Hat, Inc.")