@@ -44,15 +44,46 @@ def unlock_unity():
4444 )
4545
4646
47−def _get_unity_pid():
47+def restart_unity_with_testability():
48+ status = _get_unity_status()
49+ if "start/" in status:
50+ try:
51+ print "Stopping unity."
52+ subprocess.check_call([
53+ 'initctl',
54+ 'stop',
55+ 'unity8',
56+ ])
57+ except subprocess.CalledProcessError as e:
58+ e.args += ("Failed to stop running instance of unity8", )
59+ raise
60+
4861 try:
49− status = subprocess.check_output([
62+ print "Stopping unity with testability."
63+ subprocess.check_call([
64+ 'initctl',
65+ 'start',
66+ 'unity8',
67+ 'QT_LOAD_TESTABILITY=1',
68+ ])
69+ except subprocess.CalledProcessError as e:
70+ e.args += ("Failed to start unity8 with testability ", )
71+ raise
72+
73+
74+def _get_unity_status():
75+ try:
76+ return subprocess.check_output([
5077 'initctl',
5178 'status',
5279 'unity8'
5380 ])
54− if not "start/" in status:
55− raise CannotAccessUnity("Unity is not in the running state.")
56− return int(status.split()[-1])
5781 except subprocess.CalledProcessError as e:
5882 raise CannotAccessUnity("Unable to get unity's status: %s" % e.message)
83+
84+
85+def _get_unity_pid():
86+ status = _get_unity_status()
87+ if not "start/" in status:
88+ raise CannotAccessUnity("Unity is not in the running state.")
89+ return int(status.split()[-1])