summaryrefslogtreecommitdiff
diff options
authorJonathan Cave <jonathan.cave@canonical.com>2022-02-15 18:12:07 +0000
committerJonathan Cave <jonathan.cave@canonical.com>2022-02-15 18:12:07 +0000
commit16b6db9080236d8a2ed012f1d7834699dfb4561a (patch)
tree36bafbe6d82ee9c94eff5dee7803ce5d3533d49f
parentbff222117829e0cb8aa0ae48502461f0a899a94f (diff)
Fix: UdevadmParser in touchpad_driver_info.py
Use new API defined in checkbox-support
-rwxr-xr-xbin/touchpad_driver_info.py35
1 files changed, 12 insertions, 23 deletions
diff --git a/bin/touchpad_driver_info.py b/bin/touchpad_driver_info.py
index 9f6278f..c1c3459 100755
--- a/bin/touchpad_driver_info.py
+++ b/bin/touchpad_driver_info.py
@@ -6,19 +6,6 @@ from subprocess import Popen, PIPE, check_output, STDOUT, CalledProcessError
from checkbox_support.parsers.udevadm import UdevadmParser
from checkbox_support.parsers.modinfo import ModinfoParser
-# Command to retrieve udev information.
-COMMAND = 'udevadm info --export-db'
-
-
-class TouchResult:
-
- attributes = {}
-
- def addDevice(self, device):
- if getattr(device, 'category') == 'TOUCHPAD':
- self.attributes['driver'] = getattr(device, 'driver')
- self.attributes['product'] = getattr(device, 'product')
-
class TouchpadDriver():
@@ -48,18 +35,20 @@ class TouchpadDriver():
def get_touch_attributes():
- output, err = Popen(COMMAND, stdout=PIPE, shell=True).communicate()
+ cmd = 'udevadm info --export-db'
+ output, err = Popen(cmd, stdout=PIPE, shell=True).communicate()
if err:
- print("Error running $s" % ' '.join(COMMAND))
+ print("Error running $s" % ' '.join(cmd))
print(err)
return None
udev = UdevadmParser(StringIO(output.decode("unicode-escape")))
-
- result = TouchResult()
- udev.run(result)
-
- return result.attributes
+ attributes = {}
+ for device in udev.run():
+ if getattr(device, 'category') == 'TOUCHPAD':
+ attributes['driver'] = getattr(device, 'driver')
+ attributes['product'] = getattr(device, 'product')
+ return attributes
def main():
@@ -68,9 +57,9 @@ def main():
modinfo = TouchpadDriver(attributes['driver'])
attributes['version'] = modinfo.driver_version
print("%s: %s\n%s: %s\n%s: %s\n" % (
- 'Device', attributes['product'],
- 'Driver', attributes['driver'],
- 'Driver Version', attributes['version']))
+ 'Device', attributes['product'],
+ 'Driver', attributes['driver'],
+ 'Driver Version', attributes['version']))
else:
print("No Touchpad Detected")
return 1