| 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 |
| 11 from devtoolslib import shell_config | 11 from devtoolslib import shell_config |
| 12 | 12 |
| 13 _USAGE = ("mojo_run " | |
| 14 "[--args-for=<mojo-app>] " | |
| 15 "[--content-handlers=<handlers>] " | |
| 16 "[--enable-external-applications] " | |
| 17 "[--disable-cache] " | |
| 18 "[--enable-multiprocess] " | |
| 19 "[--wait-for-debugger] " | |
| 20 "[--sky <mojo-app>|<mojo-app>] " | |
| 21 """ | |
| 22 | |
| 23 A <mojo-app> is a Mojo URL or a Mojo URL and arguments within quotes. | |
| 24 Example: mojo_run "mojo:js_standalone test.js". | |
| 25 <url-lib-path> is searched for shared libraries named by mojo URLs. | |
| 26 The value of <handlers> is a comma separated list like: | |
| 27 text/html,mojo:html_viewer,application/javascript,mojo:js_content_handler | |
| 28 """) | |
| 29 | |
| 30 _DESCRIPTION = """Runner for Mojo applications. | 13 _DESCRIPTION = """Runner for Mojo applications. |
| 31 | 14 |
| 32 Any arguments not recognized by the script will be passed on as shell arguments. | 15 Any arguments not recognized by the script will be passed on as shell arguments. |
| 16 |
| 17 Important shell arguments include: |
| 18 "--args-for=<mojo-app-url> <arguments>" |
| 19 "--content-handlers=<handlers>" |
| 20 "--disable-cache" |
| 21 "--enable-multiprocess" |
| 22 "--wait-for-debugger" |
| 23 "<mojo-app-url>" |
| 24 "<mojo-app-url> <arguments>" |
| 25 |
| 26 The value of <handlers> is a comma separated list like: |
| 27 text/html,mojo:html_viewer,application/javascript,mojo:js_content_handler |
| 33 """ | 28 """ |
| 34 | 29 |
| 35 | |
| 36 # Port on which the mojo:debugger http server will be available on the host | 30 # Port on which the mojo:debugger http server will be available on the host |
| 37 # machine. | 31 # machine. |
| 38 _MOJO_DEBUGGER_PORT = 7777 | 32 _MOJO_DEBUGGER_PORT = 7777 |
| 39 _DEFAULT_WM = 'https://core.mojoapps.io/kiosk_wm.mojo' | 33 _DEFAULT_WM = 'https://core.mojoapps.io/kiosk_wm.mojo' |
| 40 | 34 |
| 41 _LEGACY_WM_URL = 'mojo:window_manager' | 35 _LEGACY_WM_URL = 'mojo:window_manager' |
| 42 _WM_URL = 'https://core.mojoapps.io/window_manager.mojo' | 36 _WM_URL = 'https://core.mojoapps.io/window_manager.mojo' |
| 43 _DEBUGGER_URL = 'https://core.mojoapps.io/debugger.mojo' | 37 _DEBUGGER_URL = 'https://core.mojoapps.io/debugger.mojo' |
| 44 | 38 |
| 45 | 39 |
| 46 def _configure_debugger(shell): | 40 def _configure_debugger(shell): |
| 47 """Configures debugger.mojo to run and sets up port forwarding for its http | 41 """Configures debugger.mojo to run and sets up port forwarding for its http |
| 48 server if the shell is running on a device. | 42 server if the shell is running on a device. |
| 49 | 43 |
| 50 Returns: | 44 Returns: |
| 51 Arguments that need to be appended to the shell argument list in order to | 45 Arguments that need to be appended to the shell argument list in order to |
| 52 run with the debugger. | 46 run with the debugger. |
| 53 """ | 47 """ |
| 54 shell.forward_host_port_to_shell(_MOJO_DEBUGGER_PORT) | 48 shell.forward_host_port_to_shell(_MOJO_DEBUGGER_PORT) |
| 55 return ['%s %d' % (_DEBUGGER_URL, _MOJO_DEBUGGER_PORT)] | 49 return ['%s %d' % (_DEBUGGER_URL, _MOJO_DEBUGGER_PORT)] |
| 56 | 50 |
| 57 | 51 |
| 58 def main(): | 52 def main(): |
| 59 logging.basicConfig() | 53 logging.basicConfig() |
| 60 | 54 |
| 61 parser = argparse.ArgumentParser(usage=_USAGE, description=_DESCRIPTION) | 55 parser = argparse.ArgumentParser( |
| 56 formatter_class=argparse.RawDescriptionHelpFormatter, |
| 57 description=_DESCRIPTION) |
| 62 shell_config.add_shell_arguments(parser) | 58 shell_config.add_shell_arguments(parser) |
| 63 | 59 |
| 64 parser.add_argument('--embed', type=str, | 60 parser.add_argument('--embed', type=str, |
| 65 help='Url to be embedded in the window manager.') | 61 help='Url to be embedded in the window manager.') |
| 66 parser.add_argument('--window-manager', default=_DEFAULT_WM, | 62 parser.add_argument('--window-manager', default=_DEFAULT_WM, |
| 67 help='Window manager app to be mapped as ' | 63 help='Window manager app to be mapped as ' |
| 68 'mojo:window_manager. By default it is ' + | 64 'mojo:window_manager. By default it is ' + |
| 69 _DEFAULT_WM) | 65 _DEFAULT_WM) |
| 70 parser.add_argument('--debugger', action="store_true", | 66 parser.add_argument('--debugger', action="store_true", |
| 71 help='Run debugger.mojo along with the app.') | 67 help='Run debugger.mojo along with the app.') |
| (...skipping 26 matching lines...) Expand all Loading... |
| 98 | 94 |
| 99 if script_args.verbose: | 95 if script_args.verbose: |
| 100 print "Shell arguments: " + str(shell_args) | 96 print "Shell arguments: " + str(shell_args) |
| 101 | 97 |
| 102 shell.run(shell_args) | 98 shell.run(shell_args) |
| 103 return 0 | 99 return 0 |
| 104 | 100 |
| 105 | 101 |
| 106 if __name__ == "__main__": | 102 if __name__ == "__main__": |
| 107 sys.exit(main()) | 103 sys.exit(main()) |
| OLD | NEW |