diff options
| author | PMR <pmr@pmr-lander> | 2019-05-31 11:28:00 +0000 |
|---|---|---|
| committer | PMR <pmr@pmr-lander> | 2019-05-31 11:28:00 +0000 |
| commit | cc50d5068169bc52eb6a988b4b167e78fe9aaa7b (patch) | |
| tree | 9530c5eb92f5178c5aa6414e7f0af17405aa987f | |
| parent | 7c08c187a57a20acc85d5d9e3660e123d555872d (diff) | |
| parent | 031f705cdc8c54bfe6f8fed80b0110a72ff1ccbc (diff) | |
Merge #368123 from ~jocave/plainbox-provider-checkbox:handle-missing-udev-attrs
| -rwxr-xr-x | bin/network_device_info.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/bin/network_device_info.py b/bin/network_device_info.py index e36c2012..4a827def 100755 --- a/bin/network_device_info.py +++ b/bin/network_device_info.py @@ -307,18 +307,20 @@ class UdevDevices(): """Convert to list of NetworkDevice with UDev derived attrs set""" for device in self._devices: nd = NetworkDeviceInfo() - nd.category = getattr(device, 'category') - nd.interface = getattr(device, 'interface') - nd.product = getattr(device, 'product') - nd.vendor = getattr(device, 'vendor') - nd.driver = getattr(device, 'driver') - nd.path = getattr(device, 'path') - nd.id = '[{0:04x}:{1:04x}]'.format( - getattr(device, 'vendor_id'), - getattr(device, 'product_id')) - nd.subsystem_id = '[{0:04x}:{1:04x}]'.format( - getattr(device, 'subvendor_id'), - getattr(device, 'subproduct_id')) + nd.category = getattr(device, 'category', None) + nd.interface = getattr(device, 'interface', None) + nd.product = getattr(device, 'product', None) + nd.vendor = getattr(device, 'vendor', None) + nd.driver = getattr(device, 'driver', None) + nd.path = getattr(device, 'path', None) + vid = getattr(device, 'vendor_id', None) + pid = getattr(device, 'product_id', None) + if vid and pid: + nd.id = '[{0:04x}:{1:04x}]'.format(vid, pid) + svid = getattr(device, 'subvendor_id', None) + spid = getattr(device, 'subproduct_id', None) + if svid and spid: + nd.subsystem_id = '[{0:04x}:{1:04x}]'.format(svid, spid) yield nd |
