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
=== modified file 'utils/target/unlock_screen.py'
--- utils/target/unlock_screen.py 2014-01-10 10:52:20 +0000
+++ utils/target/unlock_screen.py 2014-05-23 15:49:54 +0000
@@ -1,4 +1,6 @@
1#!/usr/bin/env python1#!/usr/bin/env python3
2
3from __future__ import print_function
24
3from autopilot import introspection5from autopilot import introspection
4from autopilot.display import Display6from autopilot.display import Display
@@ -9,46 +11,46 @@
911
1012
11def help():13def help():
12 print "Usage:"14 print("Usage:")
13 print "Run the script without any argument to unlock with assertion"15 print("Run the script without any argument to unlock with assertion")
14 print ""16 print("")
15 print "option -q:"17 print("option -q:")
16 print "Execute with parameter -q to unlock the screen quickly without introspection"18 print("Execute with parameter -q to unlock the screen quickly without introspection")
1719
1820
19def start_unity_in_testability():21def start_unity_in_testability():
20 override_file = "~/.config/upstart/unity8.override"22 override_file = "~/.config/upstart/unity8.override"
2123
22 os.system('echo "exec unity8 -testability" > ~/.config/upstart/unity8.override')24 os.system('echo "exec unity8 -testability" > ~/.config/upstart/unity8.override')
23 os.system('echo "kill timeout 30" >> ~/.config/upstart/unity8.override') 25 os.system('echo "kill timeout 30" >> ~/.config/upstart/unity8.override')
2426
25 print "----------------------------------------------------------------------"27 print("----------------------------------------------------------------------")
26 print "Stopping Unity"28 print("Stopping Unity")
27 os.system('/sbin/stop unity8')29 os.system('/sbin/stop unity8')
28 print "Unity stopped"30 print("Unity stopped")
29 os.system('rm -f /tmp/mir_socket')31 os.system('rm -f /tmp/mir_socket')
3032
31 print "----------------------------------------------------------------------"33 print("----------------------------------------------------------------------")
32 print "Taking screen lock (#1235000)"34 print("Taking screen lock (#1235000)")
33 bus = dbus.SystemBus()35 bus = dbus.SystemBus()
34 powerd = bus.get_object('com.canonical.powerd', '/com/canonical/powerd')36 powerd = bus.get_object('com.canonical.powerd', '/com/canonical/powerd')
35 powerd_cookie = powerd.requestSysState("autopilot-lock", 1, dbus_interface='com.canonical.powerd')37 powerd_cookie = powerd.requestSysState("autopilot-lock", 1, dbus_interface='com.canonical.powerd')
36 print "----------------------------------------------------------------------"38 print("----------------------------------------------------------------------")
37 print "Starting Unity with testability"39 print("Starting Unity with testability")
38 os.system('/sbin/start unity8')40 os.system('/sbin/start unity8')
39 print "Unity started"41 print("Unity started")
40 print "----------------------------------------------------------------------"42 print("----------------------------------------------------------------------")
41 print "Releasing screen lock (#1235000)"43 print("Releasing screen lock (#1235000)")
42 powerd.clearSysState(powerd_cookie, dbus_interface='com.canonical.powerd')44 powerd.clearSysState(powerd_cookie, dbus_interface='com.canonical.powerd')
4345
44 print "----------------------------------------------------------------------"46 print("----------------------------------------------------------------------")
45 if os.path.exists(override_file):47 if os.path.exists(override_file):
46 os.remove(override_file)48 os.remove(override_file)
47 print "Cleaned up upstart override"49 print("Cleaned up upstart override")
48 print "----------------------------------------------------------------------"50 print("----------------------------------------------------------------------")
4951
50 print "Turning on the screen"52 print("Turning on the screen")
51 print ""53 print("")
5254
5355
54def unlock_screen():56def unlock_screen():
@@ -65,8 +67,8 @@
65 try:67 try:
66 greeter.shown.wait_for(False)68 greeter.shown.wait_for(False)
67 except AssertionError:69 except AssertionError:
68 print "----------------------------------------------------------------------"70 print("----------------------------------------------------------------------")
69 print "THE SCREEN DIDN'T UNLOCK THE FIRST TRY, NOW ATTEMPTING A BLIND SWIPE"71 print("THE SCREEN DIDN'T UNLOCK THE FIRST TRY, NOW ATTEMPTING A BLIND SWIPE")
70 unlock_screen_blind(greeter)72 unlock_screen_blind(greeter)
7173
7274
@@ -82,11 +84,11 @@
82 try:84 try:
83 greeter.shown.wait_for(False)85 greeter.shown.wait_for(False)
84 if greeter.shown is False:86 if greeter.shown is False:
85 print ""87 print("")
86 print "THE SCREEN IS NOW UNLOCKED"88 print("THE SCREEN IS NOW UNLOCKED")
87 except AssertionError:89 except AssertionError:
88 print "----------------------------------------------------------------------"90 print("----------------------------------------------------------------------")
89 "THE SCREEN DIDN'T UNLOCK, RESTART THE DEVICE AND RUN THE SCRIPT AGAIN"91 print("THE SCREEN DIDN'T UNLOCK, RESTART THE DEVICE AND RUN THE SCRIPT AGAIN")
9092
9193
92if len(sys.argv) >= 2 and sys.argv[1] == '-q':94if len(sys.argv) >= 2 and sys.argv[1] == '-q':
9395
=== modified file 'utils/target/unlock_screen.sh'
--- utils/target/unlock_screen.sh 2014-01-04 03:16:56 +0000
+++ utils/target/unlock_screen.sh 2014-05-23 15:49:54 +0000
@@ -2,7 +2,13 @@
22
3basedir=$(dirname $(readlink -f $0))3basedir=$(dirname $(readlink -f $0))
44
5sudo -i -u phablet bash -ic "PYTHONPATH=$(pwd) ${basedir}/unlock_screen.py -q"5if which python3 >/dev/null 2>&1; then
6 python=python3
7else
8 python=python
9fi
10
11sudo -i -u phablet bash -ic "PYTHONPATH=$(pwd) ${python} ${basedir}/unlock_screen.py -q"
6rc=$?12rc=$?
713
8exit $rc14exit $rc

Subscribers

People subscribed via source and target branches