OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 from skypy.skyserver import SkyServer | 6 from skypy.skyserver import SkyServer |
7 import argparse | 7 import argparse |
8 import hashlib | 8 import hashlib |
9 import json | 9 import json |
10 import logging | 10 import logging |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 pm_output = subprocess.check_output(pm_command) | 173 pm_output = subprocess.check_output(pm_command) |
174 # e.g. package:/data/app/org.chromium.mojo.shell-1/base.apk | 174 # e.g. package:/data/app/org.chromium.mojo.shell-1/base.apk |
175 return pm_output.split(':')[-1] | 175 return pm_output.split(':')[-1] |
176 | 176 |
177 def run(self, args, pids): | 177 def run(self, args, pids): |
178 apk_path = os.path.join(args.build_dir, 'apks', APK_NAME) | 178 apk_path = os.path.join(args.build_dir, 'apks', APK_NAME) |
179 if not os.path.exists(apk_path): | 179 if not os.path.exists(apk_path): |
180 print "'%s' does not exist?" % apk_path | 180 print "'%s' does not exist?" % apk_path |
181 return 2 | 181 return 2 |
182 | 182 |
| 183 StopSky().run(args, pids) |
| 184 |
183 packages_root = dev_packages_root(args.build_dir) | 185 packages_root = dev_packages_root(args.build_dir) |
184 sky_server = self._sky_server_for_args(args, packages_root) | 186 sky_server = self._sky_server_for_args(args, packages_root) |
185 pids['sky_server_pid'] = sky_server.start() | 187 pids['sky_server_pid'] = sky_server.start() |
186 pids['sky_server_port'] = sky_server.port | 188 pids['sky_server_port'] = sky_server.port |
187 pids['sky_server_root'] = sky_server.root | 189 pids['sky_server_root'] = sky_server.root |
188 | 190 |
189 pids['build_dir'] = os.path.abspath(args.build_dir) | 191 pids['build_dir'] = os.path.abspath(args.build_dir) |
190 | 192 |
191 if args.install: | 193 if args.install: |
192 # We might need to install a new APK, so check SHA1 | 194 # We might need to install a new APK, so check SHA1 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 port_string = 'tcp:%s' % port | 377 port_string = 'tcp:%s' % port |
376 subprocess.call([ADB_PATH, 'forward', '--remove', port_string]) | 378 subprocess.call([ADB_PATH, 'forward', '--remove', port_string]) |
377 | 379 |
378 def run(self, args, pids): | 380 def run(self, args, pids): |
379 self._kill_if_exists(pids, 'sky_server_pid', 'sky_server') | 381 self._kill_if_exists(pids, 'sky_server_pid', 'sky_server') |
380 | 382 |
381 if 'remote_sky_server_port' in pids: | 383 if 'remote_sky_server_port' in pids: |
382 self._adb_reverse_remove(pids['remote_sky_server_port']) | 384 self._adb_reverse_remove(pids['remote_sky_server_port']) |
383 | 385 |
384 if 'remote_gdbserver_port' in pids: | 386 if 'remote_gdbserver_port' in pids: |
385 self._kill_if_exists('adb_shell_gdbserver_pid', | |
386 'adb shell gdbserver') | |
387 self._adb_forward_remove(pids['remote_gdbserver_port']) | 387 self._adb_forward_remove(pids['remote_gdbserver_port']) |
388 | 388 |
389 subprocess.call([ | 389 subprocess.call([ |
390 ADB_PATH, 'shell', 'am', 'force-stop', ANDROID_PACKAGE]) | 390 ADB_PATH, 'shell', 'am', 'force-stop', ANDROID_PACKAGE]) |
391 | 391 |
392 pids.clear() | 392 pids.clear() |
393 | 393 |
394 | 394 |
395 class Analyze(object): | 395 class Analyze(object): |
396 def add_subparser(self, subparsers): | 396 def add_subparser(self, subparsers): |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 args = parser.parse_args() | 493 args = parser.parse_args() |
494 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) | 494 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) |
495 exit_code = args.func(args, pids) | 495 exit_code = args.func(args, pids) |
496 # We could do this with an at-exit handler instead? | 496 # We could do this with an at-exit handler instead? |
497 pids.write_to(PID_FILE_PATH) | 497 pids.write_to(PID_FILE_PATH) |
498 sys.exit(exit_code) | 498 sys.exit(exit_code) |
499 | 499 |
500 | 500 |
501 if __name__ == '__main__': | 501 if __name__ == '__main__': |
502 SkyShellRunner().main() | 502 SkyShellRunner().main() |
OLD | NEW |