Merge lp:~fginther/autopilot/uinput-fallback into lp:autopilot

Proposed by Francis Ginther
Status: Merged
Approved by: Omer Akram
Approved revision: 212
Merged at revision: 211
Proposed branch: lp:~fginther/autopilot/uinput-fallback
Merge into: lp:autopilot
Diff against target: 62 lines (+16/-4)
2 files modified
autopilot/input/_uinput.py (+12/-2)
autopilot/tests/functional/test_input_stack.py (+4/-2)
To merge this branch: bzr merge lp:~fginther/autopilot/uinput-fallback
Reviewer Review Type Date Requested Status
Omer Akram (community) Approve
PS Jenkins bot continuous-integration Approve
Christopher Lee (community) Approve
Thomi Richards (community) Needs Fixing
Review via email: mp+164251@code.launchpad.net

Commit message

Allow fallback to /dev/uinput if /dev/autopilot-uinput does not exist.

The touch image does not support udev and therefore does not have /dev/autopilot-udev. It does have /dev/uinput. So the solution is to fallback and attempt to use /dev/uinput. This should be a short-term workaround until the touch images enable udev support.

Description of the change

Allow fallback to /dev/uinput if /dev/autopilot-uinput does not exist.

The touch image does not support udev and therefore does not have /dev/autopilot-udev. It does have /dev/uinput. So the solution is to fallback and attempt to use /dev/uinput. This should be a short-term workaround until the touch images enable udev support.

If /dev/autopilot-uinput is not present and /dev/uinput is not writable, the follow error occurs:
RuntimeError: Unable to instantiate any backends
UInput: UInputError('"/dev/uinput" cannot be opened for writing',)

om26er tested the fix on a touch image.

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

There are functional tests that need to be updated as well, specifically:

autopilot/tests/functional/test_input_stack.py line 44

review: Needs Fixing
Revision history for this message
Christopher Lee (veebers) wrote :

Looks good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
212. By Francis Ginther

Updated test_input_stack functional tests to also fallback to /dev/uinput. Renamed _get_devnode_name to _get_devnode_path.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Omer Akram (om26er) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/input/_uinput.py'
2--- autopilot/input/_uinput.py 2013-05-16 05:57:27 +0000
3+++ autopilot/input/_uinput.py 2013-05-16 20:09:25 +0000
4@@ -28,6 +28,7 @@
5 import logging
6 from time import sleep
7 from evdev import UInput, ecodes as e
8+import os.path
9
10 logger = logging.getLogger(__name__)
11
12@@ -41,7 +42,8 @@
13
14 def __init__(self):
15 super(Keyboard, self).__init__()
16- self._device = UInput(devnode='/dev/autopilot-uinput')
17+
18+ self._device = UInput(devnode=_get_devnode_path())
19
20 def _emit(self, event, value):
21 self._device.write(e.EV_KEY, event, value)
22@@ -159,6 +161,14 @@
23 return events
24
25
26+def _get_devnode_path():
27+ """Provide a fallback uinput node for devices which don't support udev"""
28+ devnode = '/dev/autopilot-uinput'
29+ if not os.path.exists(devnode):
30+ devnode = '/dev/uinput'
31+ return devnode
32+
33+
34 last_tracking_id = 0
35 def get_next_tracking_id():
36 global last_tracking_id
37@@ -215,7 +225,7 @@
38 }
39
40 return UInput(cap_mt, name='autopilot-finger', version=0x2,
41- devnode='/dev/autopilot-uinput')
42+ devnode=_get_devnode_path())
43
44 _touch_device = create_touch_device()
45
46
47=== modified file 'autopilot/tests/functional/test_input_stack.py'
48--- autopilot/tests/functional/test_input_stack.py 2013-05-15 10:13:42 +0000
49+++ autopilot/tests/functional/test_input_stack.py 2013-05-16 20:09:25 +0000
50@@ -41,8 +41,10 @@
51
52 def setUp(self):
53 super(InputStackKeyboardBase, self).setUp()
54- if self.backend == 'UInput' and not os.access('/dev/autopilot-uinput', os.W_OK):
55- raise SkipTest("UInput backend currently requires write access to /dev/autopilot-uinput")
56+ if self.backend == 'UInput' and not (
57+ os.access('/dev/autopilot-uinput', os.W_OK) or
58+ os.access('/dev/uinput', os.W_OK)):
59+ raise SkipTest("UInput backend currently requires write access to /dev/autopilot-uinput or /dev/uinput")
60
61
62 class InputStackKeyboardCreationTests(InputStackKeyboardBase):

Subscribers

People subscribed via source and target branches