| 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 sys | 8 import sys |
| 9 | 9 |
| 10 from devtoolslib import shell_arguments | 10 from devtoolslib import shell_arguments |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 """ | 33 """ |
| 34 | 34 |
| 35 | 35 |
| 36 # Port on which the mojo:debugger http server will be available on the host | 36 # Port on which the mojo:debugger http server will be available on the host |
| 37 # machine. | 37 # machine. |
| 38 _MOJO_DEBUGGER_PORT = 7777 | 38 _MOJO_DEBUGGER_PORT = 7777 |
| 39 _DEFAULT_WM = 'https://core.mojoapps.io/kiosk_wm.mojo' | 39 _DEFAULT_WM = 'https://core.mojoapps.io/kiosk_wm.mojo' |
| 40 | 40 |
| 41 _LEGACY_WM_URL = 'mojo:window_manager' | 41 _LEGACY_WM_URL = 'mojo:window_manager' |
| 42 _WM_URL = 'https://core.mojoapps.io/window_manager.mojo' | 42 _WM_URL = 'https://core.mojoapps.io/window_manager.mojo' |
| 43 _DEBUGGER_URL = 'https://core.mojoapps.io/debugger.mojo' |
| 43 | 44 |
| 44 | 45 |
| 45 def _configure_debugger(shell): | 46 def _configure_debugger(shell): |
| 46 """Configures mojo:debugger to run and sets up port forwarding for its http | 47 """Configures debugger.mojo to run and sets up port forwarding for its http |
| 47 server if the shell is running on a device. | 48 server if the shell is running on a device. |
| 48 | 49 |
| 49 Returns: | 50 Returns: |
| 50 Arguments that need to be appended to the shell argument list in order to | 51 Arguments that need to be appended to the shell argument list in order to |
| 51 run with the debugger. | 52 run with the debugger. |
| 52 """ | 53 """ |
| 53 shell.forward_host_port_to_shell(_MOJO_DEBUGGER_PORT) | 54 shell.forward_host_port_to_shell(_MOJO_DEBUGGER_PORT) |
| 54 return ['mojo:debugger %d' % _MOJO_DEBUGGER_PORT] | 55 return ['%s %d' % (_DEBUGGER_URL, _MOJO_DEBUGGER_PORT)] |
| 55 | 56 |
| 56 | 57 |
| 57 def main(): | 58 def main(): |
| 58 logging.basicConfig() | 59 logging.basicConfig() |
| 59 | 60 |
| 60 parser = argparse.ArgumentParser(usage=_USAGE, description=_DESCRIPTION) | 61 parser = argparse.ArgumentParser(usage=_USAGE, description=_DESCRIPTION) |
| 61 shell_config.add_shell_arguments(parser) | 62 shell_config.add_shell_arguments(parser) |
| 62 | 63 |
| 63 parser.add_argument('--embed', type=str, | 64 parser.add_argument('--embed', type=str, |
| 64 help='Url to be embedded in the window manager.') | 65 help='Url to be embedded in the window manager.') |
| 65 parser.add_argument('--window-manager', default=_DEFAULT_WM, | 66 parser.add_argument('--window-manager', default=_DEFAULT_WM, |
| 66 help='Window manager app to be mapped as ' | 67 help='Window manager app to be mapped as ' |
| 67 'mojo:window_manager. By default it is ' + | 68 'mojo:window_manager. By default it is ' + |
| 68 _DEFAULT_WM) | 69 _DEFAULT_WM) |
| 69 parser.add_argument('--no-debugger', action="store_true", | 70 parser.add_argument('--debugger', action="store_true", |
| 70 help='Do not spawn mojo:debugger.') | 71 help='Run debugger.mojo along with the app.') |
| 71 | 72 |
| 72 script_args, shell_args = parser.parse_known_args() | 73 script_args, shell_args = parser.parse_known_args() |
| 73 | 74 |
| 74 try: | 75 try: |
| 75 config = shell_config.get_shell_config(script_args) | 76 config = shell_config.get_shell_config(script_args) |
| 76 shell, shell_args = shell_arguments.get_shell(config, shell_args) | 77 shell, shell_args = shell_arguments.get_shell(config, shell_args) |
| 77 except shell_config.ShellConfigurationException as e: | 78 except shell_config.ShellConfigurationException as e: |
| 78 print e | 79 print e |
| 79 return 1 | 80 return 1 |
| 80 | 81 |
| 81 shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=', | 82 shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=', |
| 82 '%s=%s' % (_LEGACY_WM_URL, | 83 '%s=%s' % (_LEGACY_WM_URL, |
| 83 script_args.window_manager)) | 84 script_args.window_manager)) |
| 84 shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=', | 85 shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=', |
| 85 '%s=%s' % (_WM_URL, | 86 '%s=%s' % (_WM_URL, |
| 86 script_args.window_manager)) | 87 script_args.window_manager)) |
| 87 | 88 |
| 88 if script_args.embed: | 89 if script_args.embed: |
| 89 shell_args.append('%s %s' % (script_args.window_manager, script_args.embed)) | 90 shell_args.append('%s %s' % (script_args.window_manager, script_args.embed)) |
| 90 | 91 |
| 91 if not script_args.no_debugger: | 92 if script_args.debugger: |
| 92 if script_args.verbose: | 93 if script_args.verbose: |
| 93 print 'Spawning mojo:debugger, use `mojo_debug` to inspect the shell.' | 94 print 'Spawning mojo:debugger, use `mojo_debug` to inspect the shell.' |
| 94 print 'Note that mojo:debugger will prevent the shell from terminating,' | 95 print 'Note that mojo:debugger will prevent the shell from terminating,' |
| 95 print ' pass --no-debugger to skip spawning mojo:debugger.' | 96 print ' pass --no-debugger to skip spawning mojo:debugger.' |
| 96 shell_args.extend(_configure_debugger(shell)) | 97 shell_args.extend(_configure_debugger(shell)) |
| 97 | 98 |
| 98 if script_args.verbose: | 99 if script_args.verbose: |
| 99 print "Shell arguments: " + str(shell_args) | 100 print "Shell arguments: " + str(shell_args) |
| 100 | 101 |
| 101 shell.run(shell_args) | 102 shell.run(shell_args) |
| 102 return 0 | 103 return 0 |
| 103 | 104 |
| 104 | 105 |
| 105 if __name__ == "__main__": | 106 if __name__ == "__main__": |
| 106 sys.exit(main()) | 107 sys.exit(main()) |
| OLD | NEW |