| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Produces configured shell abstractions. | 5 """Produces configured shell abstractions. |
| 6 | 6 |
| 7 This module knows how to produce a configured shell abstraction based on | 7 This module knows how to produce a configured shell abstraction based on |
| 8 shell_config.ShellConfig. | 8 shell_config.ShellConfig. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 if not argument.startswith(key): | 138 if not argument.startswith(key): |
| 139 continue | 139 continue |
| 140 arguments[i] = argument + delimiter + value | 140 arguments[i] = argument + delimiter + value |
| 141 break | 141 break |
| 142 else: | 142 else: |
| 143 arguments.append(key + value) | 143 arguments.append(key + value) |
| 144 | 144 |
| 145 return arguments | 145 return arguments |
| 146 | 146 |
| 147 | 147 |
| 148 def _configure_dev_server(shell, shell_args, dev_server_config): | 148 def _configure_dev_server(shell, shell_args, dev_server_config, verbose): |
| 149 """Sets up a dev server on the host according to |dev_server_config|. | 149 """Sets up a dev server on the host according to |dev_server_config|. |
| 150 | 150 |
| 151 Args: | 151 Args: |
| 152 shell: The shell that is being configured. | 152 shell: The shell that is being configured. |
| 153 shell_arguments: Current list of shell arguments. | 153 shell_arguments: Current list of shell arguments. |
| 154 dev_server_config: Instance of shell_config.DevServerConfig describing the | 154 dev_server_config: Instance of shell_config.DevServerConfig describing the |
| 155 dev server to be set up. | 155 dev server to be set up. |
| 156 | 156 |
| 157 Returns: | 157 Returns: |
| 158 The updated argument list. | 158 The updated argument list. |
| 159 """ | 159 """ |
| 160 port = dev_server_config.port if dev_server_config.port else 0 | 160 port = dev_server_config.port if dev_server_config.port else 0 |
| 161 server_url = shell.serve_local_directories(dev_server_config.mappings, | 161 server_url = shell.serve_local_directories(dev_server_config.mappings, |
| 162 port=port) | 162 port=port) |
| 163 shell_args.append('--map-origin=%s=%s' % (dev_server_config.host, server_url)) | 163 shell_args.append('--map-origin=%s=%s' % (dev_server_config.host, server_url)) |
| 164 print "Configured %s locally at %s to serve:" % (dev_server_config.host, | 164 |
| 165 server_url) | 165 if verbose: |
| 166 for mapping_prefix, mapping_path in dev_server_config.mappings: | 166 print "Configured %s locally at %s to serve:" % (dev_server_config.host, |
| 167 print " /%s -> %s" % (mapping_prefix, mapping_path) | 167 server_url) |
| 168 for mapping_prefix, mapping_path in dev_server_config.mappings: |
| 169 print " /%s -> %s" % (mapping_prefix, mapping_path) |
| 168 return shell_args | 170 return shell_args |
| 169 | 171 |
| 170 | 172 |
| 171 def get_shell(shell_config, shell_args): | 173 def get_shell(shell_config, shell_args): |
| 172 """ | 174 """ |
| 173 Produces a shell abstraction configured according to |shell_config|. | 175 Produces a shell abstraction configured according to |shell_config|. |
| 174 | 176 |
| 175 Args: | 177 Args: |
| 176 shell_config: Instance of shell_config.ShellConfig. | 178 shell_config: Instance of shell_config.ShellConfig. |
| 177 shell_args: Additional raw shell arguments to be passed to the shell. We | 179 shell_args: Additional raw shell arguments to be passed to the shell. We |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 fixed_port=True)) | 220 fixed_port=True)) |
| 219 | 221 |
| 220 if shell_config.content_handlers: | 222 if shell_config.content_handlers: |
| 221 for (mime_type, | 223 for (mime_type, |
| 222 content_handler_url) in shell_config.content_handlers.iteritems(): | 224 content_handler_url) in shell_config.content_handlers.iteritems(): |
| 223 shell_args = append_to_argument(shell_args, '--content-handlers=', | 225 shell_args = append_to_argument(shell_args, '--content-handlers=', |
| 224 '%s,%s' % (mime_type, | 226 '%s,%s' % (mime_type, |
| 225 content_handler_url)) | 227 content_handler_url)) |
| 226 | 228 |
| 227 for dev_server_config in shell_config.dev_servers: | 229 for dev_server_config in shell_config.dev_servers: |
| 228 shell_args = _configure_dev_server(shell, shell_args, dev_server_config) | 230 shell_args = _configure_dev_server(shell, shell_args, dev_server_config, |
| 231 shell_config.verbose) |
| 229 | 232 |
| 230 return shell, shell_args | 233 return shell, shell_args |
| OLD | NEW |