Merge lp:~cjwatson/ubuntu-test-cases/python3 into lp:~xnox/ubuntu-test-cases/touch-emulator

Proposed by Colin Watson
Status: Needs review
Proposed branch: lp:~cjwatson/ubuntu-test-cases/python3
Merge into: lp:~xnox/ubuntu-test-cases/touch-emulator
Diff against target: 125 lines (+37/-29)
2 files modified
utils/target/unlock_screen.py (+30/-28)
utils/target/unlock_screen.sh (+7/-1)
To merge this branch: bzr merge lp:~cjwatson/ubuntu-test-cases/python3
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Pending
Review via email: mp+220822@code.launchpad.net

Commit message

Support devices with only python3.

Description of the change

Support devices with only python3.

To post a comment you must log in.

Unmerged revisions

145. By Colin Watson

Support devices with only python3.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utils/target/unlock_screen.py'
2--- utils/target/unlock_screen.py 2014-01-10 10:52:20 +0000
3+++ utils/target/unlock_screen.py 2014-05-23 15:49:54 +0000
4@@ -1,4 +1,6 @@
5-#!/usr/bin/env python
6+#!/usr/bin/env python3
7+
8+from __future__ import print_function
9
10 from autopilot import introspection
11 from autopilot.display import Display
12@@ -9,46 +11,46 @@
13
14
15 def help():
16- print "Usage:"
17- print "Run the script without any argument to unlock with assertion"
18- print ""
19- print "option -q:"
20- print "Execute with parameter -q to unlock the screen quickly without introspection"
21+ print("Usage:")
22+ print("Run the script without any argument to unlock with assertion")
23+ print("")
24+ print("option -q:")
25+ print("Execute with parameter -q to unlock the screen quickly without introspection")
26
27
28 def start_unity_in_testability():
29 override_file = "~/.config/upstart/unity8.override"
30
31 os.system('echo "exec unity8 -testability" > ~/.config/upstart/unity8.override')
32- os.system('echo "kill timeout 30" >> ~/.config/upstart/unity8.override')
33+ os.system('echo "kill timeout 30" >> ~/.config/upstart/unity8.override')
34
35- print "----------------------------------------------------------------------"
36- print "Stopping Unity"
37+ print("----------------------------------------------------------------------")
38+ print("Stopping Unity")
39 os.system('/sbin/stop unity8')
40- print "Unity stopped"
41+ print("Unity stopped")
42 os.system('rm -f /tmp/mir_socket')
43
44- print "----------------------------------------------------------------------"
45- print "Taking screen lock (#1235000)"
46+ print("----------------------------------------------------------------------")
47+ print("Taking screen lock (#1235000)")
48 bus = dbus.SystemBus()
49 powerd = bus.get_object('com.canonical.powerd', '/com/canonical/powerd')
50 powerd_cookie = powerd.requestSysState("autopilot-lock", 1, dbus_interface='com.canonical.powerd')
51- print "----------------------------------------------------------------------"
52- print "Starting Unity with testability"
53+ print("----------------------------------------------------------------------")
54+ print("Starting Unity with testability")
55 os.system('/sbin/start unity8')
56- print "Unity started"
57- print "----------------------------------------------------------------------"
58- print "Releasing screen lock (#1235000)"
59+ print("Unity started")
60+ print("----------------------------------------------------------------------")
61+ print("Releasing screen lock (#1235000)")
62 powerd.clearSysState(powerd_cookie, dbus_interface='com.canonical.powerd')
63
64- print "----------------------------------------------------------------------"
65+ print("----------------------------------------------------------------------")
66 if os.path.exists(override_file):
67 os.remove(override_file)
68- print "Cleaned up upstart override"
69- print "----------------------------------------------------------------------"
70+ print("Cleaned up upstart override")
71+ print("----------------------------------------------------------------------")
72
73- print "Turning on the screen"
74- print ""
75+ print("Turning on the screen")
76+ print("")
77
78
79 def unlock_screen():
80@@ -65,8 +67,8 @@
81 try:
82 greeter.shown.wait_for(False)
83 except AssertionError:
84- print "----------------------------------------------------------------------"
85- print "THE SCREEN DIDN'T UNLOCK THE FIRST TRY, NOW ATTEMPTING A BLIND SWIPE"
86+ print("----------------------------------------------------------------------")
87+ print("THE SCREEN DIDN'T UNLOCK THE FIRST TRY, NOW ATTEMPTING A BLIND SWIPE")
88 unlock_screen_blind(greeter)
89
90
91@@ -82,11 +84,11 @@
92 try:
93 greeter.shown.wait_for(False)
94 if greeter.shown is False:
95- print ""
96- print "THE SCREEN IS NOW UNLOCKED"
97+ print("")
98+ print("THE SCREEN IS NOW UNLOCKED")
99 except AssertionError:
100- print "----------------------------------------------------------------------"
101- "THE SCREEN DIDN'T UNLOCK, RESTART THE DEVICE AND RUN THE SCRIPT AGAIN"
102+ print("----------------------------------------------------------------------")
103+ print("THE SCREEN DIDN'T UNLOCK, RESTART THE DEVICE AND RUN THE SCRIPT AGAIN")
104
105
106 if len(sys.argv) >= 2 and sys.argv[1] == '-q':
107
108=== modified file 'utils/target/unlock_screen.sh'
109--- utils/target/unlock_screen.sh 2014-01-04 03:16:56 +0000
110+++ utils/target/unlock_screen.sh 2014-05-23 15:49:54 +0000
111@@ -2,7 +2,13 @@
112
113 basedir=$(dirname $(readlink -f $0))
114
115-sudo -i -u phablet bash -ic "PYTHONPATH=$(pwd) ${basedir}/unlock_screen.py -q"
116+if which python3 >/dev/null 2>&1; then
117+ python=python3
118+else
119+ python=python
120+fi
121+
122+sudo -i -u phablet bash -ic "PYTHONPATH=$(pwd) ${python} ${basedir}/unlock_screen.py -q"
123 rc=$?
124
125 exit $rc

Subscribers

People subscribed via source and target branches