1
0
Fork 0

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:
Tomas Korbar 2018-09-11 16:02:20 +02:00
parent 82efc4e090
commit 38ebdbeda2
2 changed files with 8 additions and 1 deletions

View file

@ -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'

View file

@ -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