package/python-hwdata: new package

Provides python interface to database stored in hwdata
package. It allows you to get human readable description of
USB and PCI devices.

https://github.com/xsuchy/python-hwdata

Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Julien Olivain 2023-03-13 22:34:39 +01:00 committed by Thomas Petazzoni
parent a2867fec00
commit 7a99e1fa29
7 changed files with 96 additions and 0 deletions

View File

@ -1715,6 +1715,7 @@ F: package/ptm2human/
F: package/python-distro/
F: package/python-gnupg/
F: package/python-hkdf/
F: package/python-hwdata/
F: package/python-magic-wormhole/
F: package/python-magic-wormhole-mailbox-server/
F: package/python-magic-wormhole-transit-relay/
@ -1727,6 +1728,7 @@ F: package/z3/
F: package/zynaddsubfx/
F: support/testing/tests/package/sample_python_distro.py
F: support/testing/tests/package/sample_python_gnupg.py
F: support/testing/tests/package/sample_python_hwdata.py
F: support/testing/tests/package/sample_python_pyalsa.py
F: support/testing/tests/package/sample_python_spake2.py
F: support/testing/tests/package/test_ddrescue.py
@ -1748,6 +1750,7 @@ F: support/testing/tests/package/test_perftest.py
F: support/testing/tests/package/test_python_distro.py
F: support/testing/tests/package/test_python_gnupg.py
F: support/testing/tests/package/test_python_hkdf.py
F: support/testing/tests/package/test_python_hwdata.py
F: support/testing/tests/package/test_python_magic_wormhole.py
F: support/testing/tests/package/test_python_pyalsa.py
F: support/testing/tests/package/test_python_spake2.py

View File

@ -1082,6 +1082,7 @@ menu "External python modules"
source "package/python-httplib2/Config.in"
source "package/python-huepy/Config.in"
source "package/python-humanize/Config.in"
source "package/python-hwdata/Config.in"
source "package/python-hyperframe/Config.in"
source "package/python-hyperlink/Config.in"
source "package/python-ibmiotf/Config.in"

View File

@ -0,0 +1,12 @@
config BR2_PACKAGE_PYTHON_HWDATA
bool "python-hwdata"
select BR2_PACKAGE_HWDATA # runtime
select BR2_PACKAGE_HWDATA_PCI_IDS
select BR2_PACKAGE_HWDATA_PNP_IDS
select BR2_PACKAGE_HWDATA_USB_IDS
help
Provides python interface to database stored in hwdata
package. It allows you to get human readable description of
USB and PCI devices.
https://github.com/xsuchy/python-hwdata

View File

@ -0,0 +1,5 @@
# md5, sha256 from https://pypi.org/pypi/hwdata/json
md5 dccf3b28d06fb9c6f56875e148356c24 hwdata-2.3.7.tar.gz
sha256 9e5c96be38d9218ffde40834d4ca03344b8dfaed29c8c5afe0030125ea03db03 hwdata-2.3.7.tar.gz
# Locally computed
sha256 ab15fd526bd8dd18a9e77ebc139656bf4d33e97fc7238cd11bf60e2b9b8666c6 LICENSE

View File

@ -0,0 +1,23 @@
################################################################################
#
# python-hwdata
#
################################################################################
PYTHON_HWDATA_VERSION = 2.3.7
PYTHON_HWDATA_SOURCE = hwdata-$(PYTHON_HWDATA_VERSION).tar.gz
PYTHON_HWDATA_SITE = https://files.pythonhosted.org/packages/15/26/f5bc1b42129fbcbd1c99c29714af1685fc89e2cf37680a9930d4fcac1808
PYTHON_HWDATA_SETUP_TYPE = distutils
PYTHON_HWDATA_LICENSE = GPL-2.0+
PYTHON_HWDATA_LICENSE_FILES = LICENSE
# There is no LICENSE file in the PyPi tarball, but it is available in
# upstream git repository:
PYTHON_HWDATA_EXTRA_DOWNLOADS = https://raw.githubusercontent.com/xsuchy/python-hwdata/python-hwdata-$(PYTHON_HWDATA_VERSION)-1/LICENSE
define PYTHON_HWDATA_ADD_LICENSE_FILE
cp $(PYTHON_HWDATA_DL_DIR)/LICENSE $(@D)
endef
PYTHON_HWDATA_POST_EXTRACT_HOOKS += PYTHON_HWDATA_ADD_LICENSE_FILE
$(eval $(python-package))

View File

@ -0,0 +1,40 @@
#! /usr/bin/env python3
from hwdata import PCI, PNP, USB
# Test PCI IDs
pci_vendor_id = '1af4'
pci_device_id = '1003'
pci = PCI()
pci_vendor = pci.get_vendor(pci_vendor_id)
print("PCI Vendor: %s" % pci_vendor)
assert (pci_vendor == "Red Hat, Inc.")
pci_device = pci.get_device(pci_vendor_id, pci_device_id)
print("PCI Device: %s" % pci_device)
assert (pci_device == "Virtio console")
# Test USB IDs
usb_vendor_id = '1d6b'
usb_device_id = '0001'
usb = USB()
usb_vendor = usb.get_vendor(usb_vendor_id)
print("USB Vendor: %s" % usb_vendor)
assert (usb_vendor == "Linux Foundation")
usb_device = usb.get_device(usb_vendor_id, usb_device_id)
print("USB Device: %s" % usb_device)
assert (usb_device == "1.1 root hub")
# Test PNP IDs
pnp_id = 'RHT'
pnp = PNP()
pnp_vendor = pnp.get_vendor(pnp_id)
print("PNP Vendor: %s" % pnp_vendor)
assert (pnp_vendor == "Red Hat, Inc.")

View File

@ -0,0 +1,12 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonHwdata(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_HWDATA=y
"""
sample_scripts = ["tests/package/sample_python_hwdata.py"]
timeout = 10