Skip to content

Commit 94c739c

Browse files
resource/udev: read uncached sysfs value via pyudev
pyudev allows unsetting cached attribute values since d935e2c ("Add device attribute unset()") [1], introduced in pyudev v0.24.4. Instead of working around udev and reading via sysfs, use that feature in USBResource.read_attr() now and bump the pyudev version requirement accordingly. [1] pyudev/pyudev@d935e2c Signed-off-by: Bastian Krause <bst@pengutronix.de>
1 parent 61dfc07 commit 94c739c

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

labgrid/resource/udev.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import queue
32
import warnings
43
from collections import OrderedDict
@@ -214,16 +213,10 @@ def model_id(self):
214213
return None
215214

216215
def read_attr(self, attribute):
217-
"""read uncached attribute value from sysfs
218-
219-
pyudev currently supports only cached access to attributes, so we read
220-
directly from sysfs.
221-
"""
222-
# FIXME update pyudev to support udev_device_set_sysattr_value(dev,
223-
# attr, None) to clear the cache
216+
"""read uncached attribute value"""
224217
if self.device is not None:
225-
with open(os.path.join(self.device.sys_path, attribute), 'rb') as f:
226-
return f.read().rstrip(b'\n') # drop trailing newlines
218+
self.device.attributes.unset(attribute)
219+
return self.device.attributes.get(attribute)
227220

228221
return None
229222

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dependencies = [
4242
"pexpect>=4.8.0",
4343
"pyserial-labgrid>=3.4.0.1",
4444
"pytest>=7.0.0",
45-
"pyudev>=0.22.0",
45+
"pyudev>=0.24.4",
4646
"pyusb>=1.2.1",
4747
"PyYAML>=6.0.1",
4848
"requests>=2.26.0",

0 commit comments

Comments
 (0)