OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 import os |
| 7 import sys |
| 8 |
| 9 # We should remove the skypy dependencies from this script. |
| 10 sys.path.append(os.path.abspath(os.path.join(__file__, '../../../sky/tools'))) |
| 11 |
6 from skypy.skyserver import SkyServer | 12 from skypy.skyserver import SkyServer |
7 import argparse | 13 import argparse |
8 import json | 14 import json |
9 import logging | 15 import logging |
10 import os | |
11 import pipes | 16 import pipes |
12 import re | 17 import re |
13 import requests | 18 import requests |
14 import signal | 19 import signal |
15 import skypy.paths | 20 import skypy.paths |
16 import StringIO | 21 import StringIO |
17 import subprocess | 22 import subprocess |
18 import sys | |
19 import time | 23 import time |
20 import urlparse | 24 import urlparse |
21 import platform | 25 import platform |
22 | 26 |
23 SUPPORTED_MIME_TYPES = [ | 27 SUPPORTED_MIME_TYPES = [ |
24 'text/html', | 28 'text/html', |
25 'text/sky', | 29 'text/sky', |
26 'text/plain', | 30 'text/plain', |
27 ] | 31 ] |
28 | 32 |
29 DEFAULT_SKY_COMMAND_PORT = 7777 | 33 DEFAULT_SKY_COMMAND_PORT = 7777 |
30 GDB_PORT = 8888 | 34 GDB_PORT = 8888 |
31 SKY_SERVER_PORT = 9999 | 35 SKY_SERVER_PORT = 9999 |
32 DEFAULT_URL = "https://raw.githubusercontent.com/domokit/mojo/master/sky/example
s/home.sky" | 36 DEFAULT_URL = "https://raw.githubusercontent.com/domokit/mojo/master/sky/example
s/home.sky" |
33 | 37 |
34 ANDROID_PACKAGE = "org.chromium.mojo.shell" | 38 ANDROID_PACKAGE = "org.chromium.mojo.shell" |
35 ANDROID_ACTIVITY = "%s/.MojoShellActivity" % ANDROID_PACKAGE | 39 ANDROID_ACTIVITY = "%s/.MojoShellActivity" % ANDROID_PACKAGE |
36 ANDROID_APK_NAME = 'MojoShell.apk' | 40 ANDROID_APK_NAME = 'MojoShell.apk' |
37 | 41 |
38 PID_FILE_PATH = "/tmp/skydb.pids" | 42 PID_FILE_PATH = "/tmp/mojodb.pids" |
39 CACHE_LINKS_PATH = '/tmp/mojo_cache_links' | 43 CACHE_LINKS_PATH = '/tmp/mojo_cache_links' |
40 | 44 |
41 SRC_ROOT = skypy.paths.Paths('ignored').src_root | 45 SRC_ROOT = skypy.paths.Paths('ignored').src_root |
42 ADB_PATH = os.path.join(SRC_ROOT, | 46 ADB_PATH = os.path.join(SRC_ROOT, |
43 'third_party/android_tools/sdk/platform-tools/adb') | 47 'third_party/android_tools/sdk/platform-tools/adb') |
44 | 48 |
45 # TODO(iansf): Fix undefined behavior when you have more than one device attache
d. | 49 # TODO(iansf): Fix undefined behavior when you have more than one device attache
d. |
46 SYSTEM_LIBS_ROOT_PATH = '/tmp/device_libs/%s' % (subprocess.check_output([ADB_PA
TH, 'get-serialno']).strip()) | 50 SYSTEM_LIBS_ROOT_PATH = '/tmp/device_libs/%s' % (subprocess.check_output([ADB_PA
TH, 'get-serialno']).strip()) |
47 | 51 |
48 | 52 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if not os.path.exists(apk_path): | 206 if not os.path.exists(apk_path): |
203 print "%s not found in build_dir '%s'" % \ | 207 print "%s not found in build_dir '%s'" % \ |
204 (ANDROID_APK_NAME, os.path.join(args.build_dir, 'apks')) | 208 (ANDROID_APK_NAME, os.path.join(args.build_dir, 'apks')) |
205 shell_found = False | 209 shell_found = False |
206 elif not os.path.exists(self.paths.mojo_shell_path): | 210 elif not os.path.exists(self.paths.mojo_shell_path): |
207 print "mojo_shell not found in build_dir '%s'" % args.build_dir | 211 print "mojo_shell not found in build_dir '%s'" % args.build_dir |
208 shell_found = False | 212 shell_found = False |
209 | 213 |
210 if not shell_found: | 214 if not shell_found: |
211 print "Are you sure you sure that's a valid build_dir location?" | 215 print "Are you sure you sure that's a valid build_dir location?" |
212 print "See skydb start --help for more info" | 216 print "See mojodb start --help for more info" |
213 sys.exit(2) | 217 sys.exit(2) |
214 | 218 |
215 if is_android and args.gdb and not 'is_debug' in gn_args: | 219 if is_android and args.gdb and not 'is_debug' in gn_args: |
216 # FIXME: We don't include gdbserver in the release APK... | 220 # FIXME: We don't include gdbserver in the release APK... |
217 print "Cannot debug Release builds on Android" | 221 print "Cannot debug Release builds on Android" |
218 sys.exit(2) | 222 sys.exit(2) |
219 | 223 |
220 dart_pkg_dir = os.path.join(self.paths.build_dir, 'gen', 'dart-pkg') | 224 dart_pkg_dir = os.path.join(self.paths.build_dir, 'gen', 'dart-pkg') |
221 packages_root = os.path.join(dart_pkg_dir, 'packages') | 225 packages_root = os.path.join(dart_pkg_dir, 'packages') |
222 | 226 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 self.pids['remote_gdbserver_port'] = GDB_PORT | 305 self.pids['remote_gdbserver_port'] = GDB_PORT |
302 | 306 |
303 if not args.gdb: | 307 if not args.gdb: |
304 if not self._wait_for_sky_command_port(): | 308 if not self._wait_for_sky_command_port(): |
305 logging.error('Failed to start sky') | 309 logging.error('Failed to start sky') |
306 self.stop_command(None) | 310 self.stop_command(None) |
307 else: | 311 else: |
308 # We could just run gdb_attach_command here, but when I do that | 312 # We could just run gdb_attach_command here, but when I do that |
309 # it auto-suspends in my zsh. Unclear why. | 313 # it auto-suspends in my zsh. Unclear why. |
310 # self.gdb_attach_command(args) | 314 # self.gdb_attach_command(args) |
311 print "Run 'skydb gdb_attach' to attach." | 315 print "Run 'mojodb gdb_attach' to attach." |
312 | 316 |
313 def _kill_if_exists(self, key, name): | 317 def _kill_if_exists(self, key, name): |
314 pid = self.pids.pop(key, None) | 318 pid = self.pids.pop(key, None) |
315 if not pid: | 319 if not pid: |
316 logging.info('No pid for %s, nothing to do.' % name) | 320 logging.info('No pid for %s, nothing to do.' % name) |
317 return | 321 return |
318 logging.info('Killing %s (%d).' % (name, pid)) | 322 logging.info('Killing %s (%d).' % (name, pid)) |
319 try: | 323 try: |
320 os.kill(pid, signal.SIGTERM) | 324 os.kill(pid, signal.SIGTERM) |
321 except OSError: | 325 except OSError: |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 start_parser.add_argument('--show-command', action='store_true', | 598 start_parser.add_argument('--show-command', action='store_true', |
595 help='Display the shell command and exit') | 599 help='Display the shell command and exit') |
596 start_parser.add_argument('--trace-startup', action='store_true') | 600 start_parser.add_argument('--trace-startup', action='store_true') |
597 start_parser.set_defaults(func=self.start_command) | 601 start_parser.set_defaults(func=self.start_command) |
598 | 602 |
599 stop_parser = subparsers.add_parser('stop', | 603 stop_parser = subparsers.add_parser('stop', |
600 help=('stop sky (as listed in %s)' % PID_FILE_PATH)) | 604 help=('stop sky (as listed in %s)' % PID_FILE_PATH)) |
601 stop_parser.set_defaults(func=self.stop_command) | 605 stop_parser.set_defaults(func=self.stop_command) |
602 | 606 |
603 pids_parser = subparsers.add_parser('pids', | 607 pids_parser = subparsers.add_parser('pids', |
604 help='dump the current skydb pids file') | 608 help='dump the current mojodb pids file') |
605 pids_parser.set_defaults(func=self.pids_command) | 609 pids_parser.set_defaults(func=self.pids_command) |
606 | 610 |
607 logcat_parser = subparsers.add_parser('logcat', | 611 logcat_parser = subparsers.add_parser('logcat', |
608 help=('dump sky-related logs from device')) | 612 help=('dump sky-related logs from device')) |
609 logcat_parser.set_defaults(func=self.logcat_command) | 613 logcat_parser.set_defaults(func=self.logcat_command) |
610 | 614 |
611 print_crash_parser = subparsers.add_parser('print_crash', | 615 print_crash_parser = subparsers.add_parser('print_crash', |
612 help=('dump (and symbolicate) recent crash-stacks')) | 616 help=('dump (and symbolicate) recent crash-stacks')) |
613 print_crash_parser.set_defaults(func=self.print_crash_command) | 617 print_crash_parser.set_defaults(func=self.print_crash_command) |
614 | 618 |
(...skipping 23 matching lines...) Expand all Loading... |
638 load_parser.set_defaults(func=self.load_command) | 642 load_parser.set_defaults(func=self.load_command) |
639 | 643 |
640 args = parser.parse_args() | 644 args = parser.parse_args() |
641 args.func(args) | 645 args.func(args) |
642 | 646 |
643 self._write_pid_file(PID_FILE_PATH, self.pids) | 647 self._write_pid_file(PID_FILE_PATH, self.pids) |
644 | 648 |
645 | 649 |
646 if __name__ == '__main__': | 650 if __name__ == '__main__': |
647 SkyDebugger().main() | 651 SkyDebugger().main() |
OLD | NEW |