19
20
def start_unity_in_testability():
20
override_file = os.path.expanduser("~/.config/upstart/unity8.override")
21
override_file = "~/.config/upstart/unity8.override"
21
23
os.system('echo "exec unity8 -testability" > ~/.config/upstart/unity8.override')
23
pid = int(subprocess.check_output(["pidof", "unity8"]))
25
print "Stopping unity"
26
os.system('stop -q unity8')
27
if os.path.exists("/proc/%d" % pid) is False:
28
print "Unity process stopped successfully"
30
print "Now starting unity in testability mode"
31
os.system('start -q unity8')
32
pid = int(subprocess.check_output(["pidof", "unity8"]))
33
if os.path.exists("/proc/%d" % pid) is True:
34
print "Unity is now started "
36
print "Cleaning up upstart override"
25
print "----------------------------------------------------------------------"
26
print "Stopping Unity"
27
os.system('/sbin/stop unity8')
29
os.system('rm -f /tmp/mir_socket')
31
print "----------------------------------------------------------------------"
32
print "Taking screen lock (#1235000)"
33
bus = dbus.SystemBus()
34
powerd = bus.get_object('com.canonical.powerd', '/com/canonical/powerd')
35
powerd_cookie = powerd.requestSysState("autopilot-lock", 1, dbus_interface='com.canonical.powerd')
36
print "----------------------------------------------------------------------"
37
print "Starting Unity with testability"
38
os.system('/sbin/start unity8')
40
print "----------------------------------------------------------------------"
41
print "Releasing screen lock (#1235000)"
42
powerd.clearSysState(powerd_cookie, dbus_interface='com.canonical.powerd')
44
print "----------------------------------------------------------------------"
37
45
if os.path.exists(override_file):
38
46
os.remove(override_file)
40
print "Attempting to unlock the screen"
47
print "Cleaned up upstart override"
48
print "----------------------------------------------------------------------"
50
print "Turning on the screen"
43
55
def unlock_screen():
47
59
unity8 = introspection.get_proxy_object_for_existing_process(connection_name=conn)
48
60
greeter = unity8.select_single("Greeter")
49
61
x, y, w, h = greeter.globalRect
53
65
pointing_device.drag(tx, ty, tx / 2, ty)
55
67
greeter.shown.wait_for(False)
56
print "THE SCREEN UNLOCKED SUCCESSFULLY"
59
print "The screen could not be unlocked, try restarting the device"
62
def unlock_screen_blind():
68
except AssertionError:
69
print "----------------------------------------------------------------------"
70
print "THE SCREEN DIDN'T UNLOCK THE FIRST TRY, NOW ATTEMPTING A BLIND SWIPE"
71
unlock_screen_blind(greeter)
74
def unlock_screen_blind(greeter=None):
63
75
input_device = Touch.create()
64
76
pointing_device = Pointer(input_device)
65
77
x, y, w, h = Display.create(preferred_backend='UPA').get_screen_geometry(0)
69
81
pointing_device.drag(tx, ty, tx / 2, ty)
82
if greeter is not None:
84
greeter.shown.wait_for(False)
85
if greeter.shown is False:
87
print "THE SCREEN IS NOW UNLOCKED"
88
except AssertionError:
89
print "----------------------------------------------------------------------"
90
"THE SCREEN DIDN'T UNLOCK, RESTART THE DEVICE AND RUN THE SCRIPT AGAIN"
72
93
if len(sys.argv) >= 2 and sys.argv[1] == '-q':