| 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 import threading | 6 import threading |
| 7 import tempfile | 7 import tempfile |
| 8 | 8 |
| 9 from devtoolslib import http_server | 9 from devtoolslib import http_server |
| 10 from devtoolslib.shell import Shell | 10 from devtoolslib.shell import Shell |
| 11 from devtoolslib.utils import overrides | 11 from devtoolslib.utils import overrides |
| 12 | 12 |
| 13 | 13 |
| 14 class LinuxShell(Shell): | 14 class LinuxShell(Shell): |
| 15 """Wrapper around Mojo shell running on Linux. | 15 """Wrapper around Mojo shell running on Linux. |
| 16 | 16 |
| 17 Args: | 17 Args: |
| 18 executable_path: path to the shell binary | 18 executable_path: path to the shell binary |
| 19 command_prefix: optional list of arguments to prepend to the shell command, | 19 command_prefix: optional list of arguments to prepend to the shell command, |
| 20 allowing e.g. to run the shell under debugger. | 20 allowing e.g. to run the shell under debugger. |
| 21 """ | 21 """ |
| 22 | 22 |
| 23 def __init__(self, executable_path, command_prefix=None): | 23 def __init__(self, executable_path, command_prefix=None): |
| 24 self.executable_path = executable_path | 24 self.executable_path = executable_path |
| 25 self.command_prefix = command_prefix if command_prefix else [] | 25 self.command_prefix = command_prefix if command_prefix else [] |
| 26 | 26 |
| 27 @overrides(Shell) | 27 @overrides(Shell) |
| 28 def serve_local_directories(self, mappings, port=0, reuse_servers=False): | 28 def serve_local_directories(self, mappings, port, reuse_servers=False): |
| 29 if reuse_servers: | 29 if reuse_servers: |
| 30 assert port, 'Cannot reuse the server when |port| is 0.' | 30 assert port, 'Cannot reuse the server when |port| is 0.' |
| 31 server_address = ('127.0.0.1', port) | 31 server_address = ('127.0.0.1', port) |
| 32 else: | 32 else: |
| 33 server_address = http_server.start_http_server(mappings, port) | 33 server_address = http_server.start_http_server(mappings, port) |
| 34 | 34 |
| 35 return 'http://%s:%d/' % server_address | 35 return 'http://%s:%d/' % server_address |
| 36 | 36 |
| 37 @overrides(Shell) | 37 @overrides(Shell) |
| 38 def forward_host_port_to_shell(self, host_port): | 38 def forward_host_port_to_shell(self, host_port): |
| (...skipping 15 matching lines...) Expand all Loading... |
| 54 wait_thread.join(timeout) | 54 wait_thread.join(timeout) |
| 55 | 55 |
| 56 did_time_out = False | 56 did_time_out = False |
| 57 if p.poll() is None: | 57 if p.poll() is None: |
| 58 did_time_out = True | 58 did_time_out = True |
| 59 p.terminate() | 59 p.terminate() |
| 60 p.poll() | 60 p.poll() |
| 61 output_file.seek(0) | 61 output_file.seek(0) |
| 62 output = output_file.read() | 62 output = output_file.read() |
| 63 return p.returncode, output, did_time_out | 63 return p.returncode, output, did_time_out |
| OLD | NEW |