diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2014-07-23 09:42:47 +1000 |
---|---|---|
committer | Benjamin Tissoires <benjamin.tissoires@gmail.com> | 2014-07-28 09:18:15 -0400 |
commit | 45f5370e95ce4524865ad4af436cd30acbd315d1 (patch) | |
tree | b728c01361dba3c055fd323dad92645185263e7a /python | |
parent | 1b572c4a482e7ae8ea7f664d4245e8c77fded5e1 (diff) |
python: add an extra flag to evemu.Device.__init__ to avoid uinput creation
If we're just reading a file for info, we don't need to create a uinput
device.
This means we can now use the conversion script without being root. Oh, the
progress!
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Diffstat (limited to 'python')
-rw-r--r-- | python/evemu/__init__.py | 7 | ||||
-rw-r--r-- | python/evemu/tests/test_device.py | 14 |
2 files changed, 19 insertions, 2 deletions
diff --git a/python/evemu/__init__.py b/python/evemu/__init__.py index 4f64204..65c7cf0 100644 --- a/python/evemu/__init__.py +++ b/python/evemu/__init__.py @@ -35,7 +35,7 @@ class Device(object): reported by the kernel or a pseudodevice as created through a .prop file. """ - def __init__(self, f): + def __init__(self, f, create=True): """ Initializas an evemu Device. @@ -43,6 +43,8 @@ class Device(object): f -- a file object or filename string for either an existing input device node (/dev/input/eventNN) or an evemu prop file that can be used to create a pseudo-device node. + create -- If f points to an evemu prop file, 'create' specifies if a + uinput device should be created """ if type(f) == str: @@ -61,7 +63,8 @@ class Device(object): if self._is_propfile: fs = self._libc.fdopen(self._file.fileno(), b"r") self._libevemu.evemu_read(self._evemu_device, fs) - self._file = self._create_devnode() + if create: + self._file = self._create_devnode() else: self._libevemu.evemu_extract(self._evemu_device, self._file.fileno()) diff --git a/python/evemu/tests/test_device.py b/python/evemu/tests/test_device.py index faca6ad..51a0050 100644 --- a/python/evemu/tests/test_device.py +++ b/python/evemu/tests/test_device.py @@ -64,6 +64,13 @@ class DeviceActionTestCase(evemu.testing.testcase.BaseTestCase): """ d = evemu.Device(self.get_device_file()) + def test_construct_from_prop_file_name_no_create(self): + """ + Verifies a device can be constructed from an evemu prop file name, + without creating a uinput device. + """ + d = evemu.Device(self.get_device_file(), create=False) + def test_construct_from_prop_file_file(self): """ Verifies a device can be constructed from an evemu prop file file @@ -71,6 +78,13 @@ class DeviceActionTestCase(evemu.testing.testcase.BaseTestCase): """ d = evemu.Device(open(self.get_device_file())) + def test_construct_from_prop_file_file(self): + """ + Verifies a device can be constructed from an evemu prop file file + object, without creating a uinput device. + """ + d = evemu.Device(open(self.get_device_file()), create=False) + def test_describe(self): """ Verifies that a device description can be correctly extracted from a |