Fix deprecation warnings when python 3 is used
- we should use pyudev.Device class property 'properties' for accesing device properties - but we still need to keep try catch workaround because of old pyudev package which is present in centos
This commit is contained in:
parent
82efc4e090
commit
38ebdbeda2
2 changed files with 8 additions and 1 deletions
|
|
@ -188,6 +188,7 @@ class DummyDevice(Mapping):
|
|||
def __init__(self,sysname,dictionary,*args,**kwargs):
|
||||
super(DummyDevice,self).__init__(*args,**kwargs)
|
||||
self.dictionary = dictionary
|
||||
self.properties = dictionary
|
||||
self.sys_name = sysname
|
||||
self.setting = '101'
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,13 @@ class DeviceMatcherUdev(device_matcher.DeviceMatcher):
|
|||
"""
|
||||
|
||||
properties = ''
|
||||
for key, val in list(device.items()):
|
||||
|
||||
try:
|
||||
items = device.properties.items()
|
||||
except AttributeError:
|
||||
items = device.items()
|
||||
|
||||
for key, val in list(items):
|
||||
properties += key + '=' + val + '\n'
|
||||
|
||||
return re.search(regex, properties, re.MULTILINE) is not None
|
||||
|
|
|
|||
Loading…
Reference in a new issue