python-hwdata提供了Python接口用于访问hwdata包的数据库数据,允许你读取USB和PCI设备的描述信息。
示例代码:
#!/usr/bin/pythonfromhwdataimportPCI,USB#forobtainingrealidofyourdevicesyoucanusepackagepython-gudevpci_vendor_id='0e11'pci_device_id='b01e'usb_vendor_id='03f0'usb_device_id='1f12'pci=PCI()print("Vendor:%s"%pci.get_vendor(pci_vendor_id))print("Device:%s"%pci.get_device(pci_vendor_id,pci_device_id))usb=USB()print("Vendor:%s"%usb.get_vendor(usb_vendor_id))print("Device:%s"%usb.get_device(usb_vendor_id,usb_device_id))
评论