| 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 argparse | 6 import argparse |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 import urlparse | 10 import urlparse |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 str(HTTP_PORT), | 58 str(HTTP_PORT), |
| 59 ] | 59 ] |
| 60 self._sky_server = subprocess.Popen(server_command) | 60 self._sky_server = subprocess.Popen(server_command) |
| 61 return 'http://localhost:%s/%s' % (HTTP_PORT, relative_path) | 61 return 'http://localhost:%s/%s' % (HTTP_PORT, relative_path) |
| 62 | 62 |
| 63 def main(self): | 63 def main(self): |
| 64 logging.basicConfig(level=logging.INFO) | 64 logging.basicConfig(level=logging.INFO) |
| 65 | 65 |
| 66 parser = argparse.ArgumentParser(description='Sky launcher/debugger') | 66 parser = argparse.ArgumentParser(description='Sky launcher/debugger') |
| 67 parser.add_argument('--gdb', action='store_true') | 67 parser.add_argument('--gdb', action='store_true') |
| 68 parser.add_argument('--use-osmesa', action='store_true') |
| 68 parser.add_argument('url', nargs='?', type=str) | 69 parser.add_argument('url', nargs='?', type=str) |
| 69 args = parser.parse_args() | 70 args = parser.parse_args() |
| 70 | 71 |
| 71 content_handlers = ['%s,%s' % (mime_type, 'mojo://sky_viewer/') | 72 content_handlers = ['%s,%s' % (mime_type, 'mojo://sky_viewer/') |
| 72 for mime_type in SUPPORTED_MIME_TYPES] | 73 for mime_type in SUPPORTED_MIME_TYPES] |
| 73 shell_command = [ | 74 shell_command = [ |
| 74 MOJO_SHELL_PATH, | 75 MOJO_SHELL_PATH, |
| 75 '--v=1', | 76 '--v=1', |
| 76 '--content-handlers=%s' % ','.join(content_handlers), | 77 '--content-handlers=%s' % ','.join(content_handlers), |
| 77 '--url-mappings=mojo:window_manager=mojo:sky_debugger', | 78 '--url-mappings=mojo:window_manager=mojo:sky_debugger', |
| 78 'mojo:window_manager', | 79 'mojo:window_manager', |
| 79 ] | 80 ] |
| 80 if args.url: | 81 if args.url: |
| 81 url = args.url | 82 url = args.url |
| 82 if not urlparse.urlparse(url).scheme: | 83 if not urlparse.urlparse(url).scheme: |
| 83 url = self._start_http_server_for_file(url) | 84 url = self._start_http_server_for_file(url) |
| 84 | 85 |
| 85 prompt_args = '--args-for=mojo://sky_debugger_prompt/ %s' % url | 86 prompt_args = '--args-for=mojo://sky_debugger_prompt/ %s' % url |
| 86 shell_command.append(prompt_args) | 87 shell_command.append(prompt_args) |
| 88 if args.use_osmesa: |
| 89 shell_command.append('--args-for=mojo://native_viewport_service/ --u
se-osmesa') |
| 87 if args.gdb: | 90 if args.gdb: |
| 88 shell_command = ['gdb', '--args'] + shell_command | 91 shell_command = ['gdb', '--args'] + shell_command |
| 89 | 92 |
| 90 subprocess.check_call(shell_command) | 93 subprocess.check_call(shell_command) |
| 91 | 94 |
| 92 def shutdown(self): | 95 def shutdown(self): |
| 93 print "Quitting" | 96 print "Quitting" |
| 94 if self._sky_server: | 97 if self._sky_server: |
| 95 self._sky_server.terminate() | 98 self._sky_server.terminate() |
| 96 | 99 |
| 97 | 100 |
| 98 if __name__ == '__main__': | 101 if __name__ == '__main__': |
| 99 skydb = SkyDebugger() | 102 skydb = SkyDebugger() |
| 100 try: | 103 try: |
| 101 skydb.main() | 104 skydb.main() |
| 102 except (KeyboardInterrupt, SystemExit): | 105 except (KeyboardInterrupt, SystemExit): |
| 103 pass | 106 pass |
| 104 finally: | 107 finally: |
| 105 skydb.shutdown() | 108 skydb.shutdown() |
| OLD | NEW |