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 """Configuration for the shell abstraction. | 5 """Configuration for the shell abstraction. |
6 | 6 |
7 This module declares ShellConfig and knows how to compute it from command-line | 7 This module declares ShellConfig and knows how to compute it from command-line |
8 arguments, applying any default paths inferred from the checkout, configuration | 8 arguments, applying any default paths inferred from the checkout, configuration |
9 file, etc. | 9 file, etc. |
10 """ | 10 """ |
(...skipping 30 matching lines...) Expand all Loading... |
41 # Desktop-only. | 41 # Desktop-only. |
42 self.use_osmesa = None | 42 self.use_osmesa = None |
43 | 43 |
44 | 44 |
45 class DevServerConfig(object): | 45 class DevServerConfig(object): |
46 """Configuration for a development server running on a host and available to | 46 """Configuration for a development server running on a host and available to |
47 the shell. | 47 the shell. |
48 """ | 48 """ |
49 def __init__(self): | 49 def __init__(self): |
50 self.host = None | 50 self.host = None |
| 51 self.port = None |
51 self.mappings = None | 52 self.mappings = None |
52 | 53 |
53 | 54 |
54 def add_shell_arguments(parser): | 55 def add_shell_arguments(parser): |
55 """Adds argparse arguments allowing to configure shell abstraction using | 56 """Adds argparse arguments allowing to configure shell abstraction using |
56 configure_shell() below. | 57 configure_shell() below. |
57 """ | 58 """ |
58 # Arguments configuring the shell run. | 59 # Arguments configuring the shell run. |
59 parser.add_argument('--android', help='Run on Android', | 60 parser.add_argument('--android', help='Run on Android', |
60 action='store_true') | 61 action='store_true') |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 config = _read_config_file(config_file, config_file_aliases) | 187 config = _read_config_file(config_file, config_file_aliases) |
187 except SyntaxError: | 188 except SyntaxError: |
188 raise ShellConfigurationException('Failed to parse the mojoconfig ' | 189 raise ShellConfigurationException('Failed to parse the mojoconfig ' |
189 'file.') | 190 'file.') |
190 | 191 |
191 if 'dev_servers' in config: | 192 if 'dev_servers' in config: |
192 try: | 193 try: |
193 for dev_server_spec in config['dev_servers']: | 194 for dev_server_spec in config['dev_servers']: |
194 dev_server_config = DevServerConfig() | 195 dev_server_config = DevServerConfig() |
195 dev_server_config.host = dev_server_spec['host'] | 196 dev_server_config.host = dev_server_spec['host'] |
| 197 dev_server_config.port = dev_server_spec.get('port', None) |
196 dev_server_config.mappings = [] | 198 dev_server_config.mappings = [] |
197 for prefix, path in dev_server_spec['mappings']: | 199 for prefix, path in dev_server_spec['mappings']: |
198 dev_server_config.mappings.append((prefix, path)) | 200 dev_server_config.mappings.append((prefix, path)) |
199 shell_config.dev_servers.append(dev_server_config) | 201 shell_config.dev_servers.append(dev_server_config) |
200 except (ValueError, KeyError): | 202 except (ValueError, KeyError): |
201 raise ShellConfigurationException('Failed to parse dev_servers in ' | 203 raise ShellConfigurationException('Failed to parse dev_servers in ' |
202 'the config file.') | 204 'the config file.') |
203 | 205 |
204 if 'content_handlers' in config: | 206 if 'content_handlers' in config: |
205 try: | 207 try: |
206 for (mime_type, | 208 for (mime_type, |
207 content_handler_url) in config['content_handlers'].iteritems(): | 209 content_handler_url) in config['content_handlers'].iteritems(): |
208 shell_config.content_handlers[mime_type] = content_handler_url | 210 shell_config.content_handlers[mime_type] = content_handler_url |
209 except (ValueError, KeyError): | 211 except (ValueError, KeyError): |
210 raise ShellConfigurationException('Failed to parse content_handlers in ' | 212 raise ShellConfigurationException('Failed to parse content_handlers in ' |
211 'the config file.') | 213 'the config file.') |
212 return shell_config | 214 return shell_config |
OLD | NEW |