| 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 import subprocess | 5 import subprocess |
| 6 | 6 |
| 7 from devtoolslib.shell import Shell | 7 from devtoolslib.shell import Shell |
| 8 from devtoolslib import http_server | 8 from devtoolslib import http_server |
| 9 | 9 |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 Args: | 32 Args: |
| 33 local_dir_path: path to the directory to be served | 33 local_dir_path: path to the directory to be served |
| 34 port: port at which the server will be available to the shell | 34 port: port at which the server will be available to the shell |
| 35 additional_mappings: List of tuples (prefix, local_base_path) mapping | 35 additional_mappings: List of tuples (prefix, local_base_path) mapping |
| 36 URLs that start with |prefix| to local directory at |local_base_path|. | 36 URLs that start with |prefix| to local directory at |local_base_path|. |
| 37 The prefixes should skip the leading slash. | 37 The prefixes should skip the leading slash. |
| 38 | 38 |
| 39 Returns: | 39 Returns: |
| 40 The url that the shell can use to access the content of |local_dir_path|. | 40 The url that the shell can use to access the content of |local_dir_path|. |
| 41 """ | 41 """ |
| 42 return 'http://%s:%d/' % http_server.StartHttpServer(local_dir_path, port, | 42 return 'http://%s:%d/' % http_server.start_http_server(local_dir_path, port, |
| 43 additional_mappings) | 43 additional_mappings) |
| 44 | 44 |
| 45 def ForwardHostPortToShell(self, host_port): | 45 def ForwardHostPortToShell(self, host_port): |
| 46 """Forwards a port on the host machine to the same port wherever the shell | 46 """Forwards a port on the host machine to the same port wherever the shell |
| 47 is running. | 47 is running. |
| 48 | 48 |
| 49 This is a no-op if the shell is running locally. | 49 This is a no-op if the shell is running locally. |
| 50 """ | 50 """ |
| 51 pass | 51 pass |
| 52 | 52 |
| 53 def Run(self, arguments): | 53 def Run(self, arguments): |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 Returns: | 70 Returns: |
| 71 A tuple of (return_code, output). |return_code| is the exit code returned | 71 A tuple of (return_code, output). |return_code| is the exit code returned |
| 72 by the shell or None if the exit code cannot be retrieved. |output| is the | 72 by the shell or None if the exit code cannot be retrieved. |output| is the |
| 73 stdout mingled with the stderr produced by the shell. | 73 stdout mingled with the stderr produced by the shell. |
| 74 """ | 74 """ |
| 75 command = self.command_prefix + [self.executable_path] + arguments | 75 command = self.command_prefix + [self.executable_path] + arguments |
| 76 p = subprocess.Popen(command, stdout=subprocess.PIPE, | 76 p = subprocess.Popen(command, stdout=subprocess.PIPE, |
| 77 stderr=subprocess.STDOUT) | 77 stderr=subprocess.STDOUT) |
| 78 (output, _) = p.communicate() | 78 (output, _) = p.communicate() |
| 79 return p.returncode, output | 79 return p.returncode, output |
| OLD | NEW |