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 logging | 7 import logging |
8 import os | 8 import os |
9 from skypy.paths import Paths | 9 from skypy.paths import Paths |
10 import skypy.configuration as configuration | 10 import skypy.configuration as configuration |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 def _in_chromoting(self): | 64 def _in_chromoting(self): |
65 return os.environ.get('CHROME_REMOTE_DESKTOP_SESSION', False) | 65 return os.environ.get('CHROME_REMOTE_DESKTOP_SESSION', False) |
66 | 66 |
67 def main(self): | 67 def main(self): |
68 logging.basicConfig(level=logging.INFO) | 68 logging.basicConfig(level=logging.INFO) |
69 | 69 |
70 parser = argparse.ArgumentParser(description='Sky launcher/debugger') | 70 parser = argparse.ArgumentParser(description='Sky launcher/debugger') |
71 parser.add_argument('--gdb', action='store_true') | 71 parser.add_argument('--gdb', action='store_true') |
72 parser.add_argument('--use-osmesa', action='store_true', | 72 parser.add_argument('--use-osmesa', action='store_true', |
73 default=self._in_chromoting()) | 73 default=self._in_chromoting()) |
74 parser.add_argument('--show_command', action='store_true', | |
abarth-chromium
2015/01/07 22:52:01
--show_command -> --show-command (for consistency
hansmuller1
2015/01/07 23:33:04
Done.
| |
75 help='Display the shell command and exit') | |
74 parser.add_argument('url', nargs='?', type=str) | 76 parser.add_argument('url', nargs='?', type=str) |
75 configuration.add_arguments(parser) | 77 configuration.add_arguments(parser) |
76 args = parser.parse_args() | 78 args = parser.parse_args() |
77 | 79 |
78 self.paths = Paths(os.path.join('out', args.configuration)) | 80 self.paths = Paths(os.path.join('out', args.configuration)) |
79 | 81 |
80 content_handlers = ['%s,%s' % (mime_type, 'mojo:sky_viewer') | 82 content_handlers = ['%s,%s' % (mime_type, 'mojo:sky_viewer') |
81 for mime_type in SUPPORTED_MIME_TYPES] | 83 for mime_type in SUPPORTED_MIME_TYPES] |
82 shell_command = [ | 84 shell_command = [ |
83 self.paths.mojo_shell_path, | 85 self.paths.mojo_shell_path, |
84 '--v=1', | 86 '--v=1', |
85 '--content-handlers=%s' % ','.join(content_handlers), | 87 '--content-handlers=%s' % ','.join(content_handlers), |
86 '--url-mappings=mojo:window_manager=mojo:sky_debugger', | 88 '--url-mappings=mojo:window_manager=mojo:sky_debugger', |
87 'mojo:window_manager', | 89 'mojo:window_manager', |
88 ] | 90 ] |
89 if args.url: | 91 if args.url: |
90 url = args.url | 92 url = args.url |
91 if not urlparse.urlparse(url).scheme: | 93 if not urlparse.urlparse(url).scheme: |
92 url = self._start_http_server_for_file(url, args.configuration) | 94 url = self._start_http_server_for_file(url, args.configuration) |
93 | 95 |
94 prompt_args = '--args-for=mojo:sky_debugger_prompt %s' % url | 96 prompt_args = '--args-for=mojo:sky_debugger_prompt %s' % url |
95 shell_command.append(prompt_args) | 97 shell_command.append(prompt_args) |
96 if args.use_osmesa: | 98 if args.use_osmesa: |
97 shell_command.append('--args-for=mojo:native_viewport_service --use- osmesa') | 99 shell_command.append('--args-for=mojo:native_viewport_service --use- osmesa') |
98 if args.gdb: | 100 if args.gdb: |
99 shell_command = ['gdb', '--args'] + shell_command | 101 shell_command = ['gdb', '--args'] + shell_command |
100 | 102 |
101 subprocess.check_call(shell_command) | 103 if args.show_command: |
104 print " ".join(shell_command) | |
105 else: | |
106 subprocess.check_call(shell_command) | |
102 | 107 |
103 def shutdown(self): | 108 def shutdown(self): |
104 print "Quitting" | 109 print "Quitting" |
105 if self._sky_server: | 110 if self._sky_server: |
106 self._sky_server.terminate() | 111 self._sky_server.terminate() |
107 | 112 |
108 | 113 |
109 if __name__ == '__main__': | 114 if __name__ == '__main__': |
110 skydb = SkyDebugger() | 115 skydb = SkyDebugger() |
111 try: | 116 try: |
112 skydb.main() | 117 skydb.main() |
113 except (KeyboardInterrupt, SystemExit): | 118 except (KeyboardInterrupt, SystemExit): |
114 pass | 119 pass |
115 finally: | 120 finally: |
116 skydb.shutdown() | 121 skydb.shutdown() |
OLD | NEW |