| 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 |
| 11 import os.path | 11 import os.path |
| 12 import sys | |
| 13 import urlparse | 12 import urlparse |
| 14 | 13 |
| 15 from devtoolslib.android_shell import AndroidShell | 14 from devtoolslib.android_shell import AndroidShell |
| 16 from devtoolslib.linux_shell import LinuxShell | 15 from devtoolslib.linux_shell import LinuxShell |
| 17 from devtoolslib.shell_config import ShellConfigurationException | 16 from devtoolslib.shell_config import ShellConfigurationException |
| 18 | 17 |
| 19 # When spinning up servers for local origins, we want to use predictable ports | 18 # When spinning up servers for local origins, we want to use predictable ports |
| 20 # so that caching works between subsequent runs with the same command line. | 19 # so that caching works between subsequent runs with the same command line. |
| 21 _LOCAL_ORIGIN_PORT = 31840 | 20 _LOCAL_ORIGIN_PORT = 31840 |
| 22 _MAPPINGS_BASE_PORT = 31841 | 21 _MAPPINGS_BASE_PORT = 31841 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 overrides and the existing value into just one argument. | 187 overrides and the existing value into just one argument. |
| 189 | 188 |
| 190 Returns: | 189 Returns: |
| 191 A tuple of (shell, shell_args). |shell| is the configured shell abstraction, | 190 A tuple of (shell, shell_args). |shell| is the configured shell abstraction, |
| 192 |shell_args| is updated list of shell arguments. | 191 |shell_args| is updated list of shell arguments. |
| 193 | 192 |
| 194 Throws: | 193 Throws: |
| 195 ShellConfigurationException if shell abstraction could not be configured. | 194 ShellConfigurationException if shell abstraction could not be configured. |
| 196 """ | 195 """ |
| 197 if shell_config.android: | 196 if shell_config.android: |
| 198 verbose_pipe = sys.stdout if shell_config.verbose else None | |
| 199 | |
| 200 shell = AndroidShell(shell_config.adb_path, shell_config.target_device, | 197 shell = AndroidShell(shell_config.adb_path, shell_config.target_device, |
| 201 logcat_tags=shell_config.logcat_tags, | 198 logcat_tags=shell_config.logcat_tags, |
| 202 verbose_pipe=verbose_pipe) | 199 verbose=shell_config.verbose) |
| 203 | 200 |
| 204 device_status, error = shell.check_device( | 201 device_status, error = shell.check_device( |
| 205 require_root=shell_config.require_root) | 202 require_root=shell_config.require_root) |
| 206 if not device_status: | 203 if not device_status: |
| 207 raise ShellConfigurationException('Device check failed: ' + error) | 204 raise ShellConfigurationException('Device check failed: ' + error) |
| 208 if shell_config.shell_path: | 205 if shell_config.shell_path: |
| 209 shell.install_apk(shell_config.shell_path) | 206 shell.install_apk(shell_config.shell_path) |
| 210 else: | 207 else: |
| 211 if not shell_config.shell_path: | 208 if not shell_config.shell_path: |
| 212 raise ShellConfigurationException('Can not run without a shell binary. ' | 209 raise ShellConfigurationException('Can not run without a shell binary. ' |
| (...skipping 21 matching lines...) Expand all Loading... |
| 234 shell_args = append_to_argument(shell_args, '--content-handlers=', | 231 shell_args = append_to_argument(shell_args, '--content-handlers=', |
| 235 '%s,%s' % (mime_type, | 232 '%s,%s' % (mime_type, |
| 236 content_handler_url)) | 233 content_handler_url)) |
| 237 | 234 |
| 238 for dev_server_config in shell_config.dev_servers: | 235 for dev_server_config in shell_config.dev_servers: |
| 239 shell_args = _configure_dev_server(shell, shell_args, dev_server_config, | 236 shell_args = _configure_dev_server(shell, shell_args, dev_server_config, |
| 240 shell_config.reuse_servers, | 237 shell_config.reuse_servers, |
| 241 shell_config.verbose) | 238 shell_config.verbose) |
| 242 | 239 |
| 243 return shell, shell_args | 240 return shell, shell_args |
| OLD | NEW |