Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: mojo/devtools/common/mojo_run

Issue 1283733002: Add mojo_run --embed APP_URL and update wm urls. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Improve the comments. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/devtools/common/README.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18 matching lines...) Expand all
29 29
30 _DESCRIPTION = """Runner for Mojo applications. 30 _DESCRIPTION = """Runner for Mojo applications.
31 31
32 Any arguments not recognized by the script will be passed on as shell arguments. 32 Any arguments not recognized by the script will be passed on as shell arguments.
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_WINDOW_MANAGER = "mojo:kiosk_wm" 39 _DEFAULT_WM = 'https://core.mojoapps.io/kiosk_wm.mojo'
etiennej 2015/08/10 11:18:50 As I understand it, this CL changes the default wi
ppi 2015/08/10 11:30:41 When running within a mojo checkout, https://core.
40
41 _LEGACY_WM_URL = 'mojo:window_manager'
42 _WM_URL = 'https://core.mojoapps.io/window_manager.mojo'
40 43
41 44
42 def _configure_debugger(shell): 45 def _configure_debugger(shell):
43 """Configures mojo:debugger to run and sets up port forwarding for its http 46 """Configures mojo:debugger to run and sets up port forwarding for its http
44 server if the shell is running on a device. 47 server if the shell is running on a device.
45 48
46 Returns: 49 Returns:
47 Arguments that need to be appended to the shell argument list in order to 50 Arguments that need to be appended to the shell argument list in order to
48 run with the debugger. 51 run with the debugger.
49 """ 52 """
50 shell.forward_host_port_to_shell(_MOJO_DEBUGGER_PORT) 53 shell.forward_host_port_to_shell(_MOJO_DEBUGGER_PORT)
51 return ['mojo:debugger %d' % _MOJO_DEBUGGER_PORT] 54 return ['mojo:debugger %d' % _MOJO_DEBUGGER_PORT]
52 55
53 56
54 def main(): 57 def main():
55 logging.basicConfig() 58 logging.basicConfig()
56 59
57 parser = argparse.ArgumentParser(usage=_USAGE, description=_DESCRIPTION) 60 parser = argparse.ArgumentParser(usage=_USAGE, description=_DESCRIPTION)
58 shell_config.add_shell_arguments(parser) 61 shell_config.add_shell_arguments(parser)
59 62
63 parser.add_argument('--embed', type=str,
64 help='Url to be embedded in the window manager.')
65 parser.add_argument('--window-manager', default=_DEFAULT_WM,
66 help='Window manager app to be mapped as '
67 'mojo:window_manager. By default it is ' +
68 _DEFAULT_WM)
60 parser.add_argument('--no-debugger', action="store_true", 69 parser.add_argument('--no-debugger', action="store_true",
61 help='Do not spawn mojo:debugger.') 70 help='Do not spawn mojo:debugger.')
62 parser.add_argument('--window-manager', default=_DEFAULT_WINDOW_MANAGER,
63 help='Window manager app to be mapped as '
64 'mojo:window_manager. By default it is ' +
65 _DEFAULT_WINDOW_MANAGER)
66 71
67 script_args, shell_args = parser.parse_known_args() 72 script_args, shell_args = parser.parse_known_args()
68 73
69 try: 74 try:
70 config = shell_config.get_shell_config(script_args) 75 config = shell_config.get_shell_config(script_args)
71 shell, shell_args = shell_arguments.get_shell(config, shell_args) 76 shell, shell_args = shell_arguments.get_shell(config, shell_args)
72 except shell_config.ShellConfigurationException as e: 77 except shell_config.ShellConfigurationException as e:
73 print e 78 print e
74 return 1 79 return 1
75 80
81 shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=',
82 '%s=%s' % (_LEGACY_WM_URL,
83 script_args.window_manager))
84 shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=',
85 '%s=%s' % (_WM_URL,
86 script_args.window_manager))
87
88 if script_args.embed:
89 shell_args.append('%s %s' % (script_args.window_manager, script_args.embed))
90
76 if not script_args.no_debugger: 91 if not script_args.no_debugger:
77 if script_args.verbose: 92 if script_args.verbose:
78 print 'Spawning mojo:debugger, use `mojo_debug` to inspect the shell.' 93 print 'Spawning mojo:debugger, use `mojo_debug` to inspect the shell.'
79 print 'Note that mojo:debugger will prevent the shell from terminating,' 94 print 'Note that mojo:debugger will prevent the shell from terminating,'
80 print ' pass --no-debugger to skip spawning mojo:debugger.' 95 print ' pass --no-debugger to skip spawning mojo:debugger.'
81 shell_args.extend(_configure_debugger(shell)) 96 shell_args.extend(_configure_debugger(shell))
82 97
83 shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=',
84 'mojo:window_manager=%s' %
85 script_args.window_manager)
86
87 if script_args.verbose: 98 if script_args.verbose:
88 print "Shell arguments: " + str(shell_args) 99 print "Shell arguments: " + str(shell_args)
89 100
90 shell.run(shell_args) 101 shell.run(shell_args)
91 return 0 102 return 0
92 103
93 104
94 if __name__ == "__main__": 105 if __name__ == "__main__":
95 sys.exit(main()) 106 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/devtools/common/README.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698