| 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 | 7 |
| 8 from devtoolslib import http_server | 8 from devtoolslib import http_server |
| 9 from devtoolslib.shell import Shell | 9 from devtoolslib.shell import Shell |
| 10 from devtoolslib.utils import overrides | 10 from devtoolslib.utils import overrides |
| 11 | 11 |
| 12 | 12 |
| 13 class LinuxShell(Shell): | 13 class LinuxShell(Shell): |
| 14 """Wrapper around Mojo shell running on Linux. | 14 """Wrapper around Mojo shell running on Linux. |
| 15 | 15 |
| 16 Args: | 16 Args: |
| 17 executable_path: path to the shell binary | 17 executable_path: path to the shell binary |
| 18 command_prefix: optional list of arguments to prepend to the shell command, | 18 command_prefix: optional list of arguments to prepend to the shell command, |
| 19 allowing e.g. to run the shell under debugger. | 19 allowing e.g. to run the shell under debugger. |
| 20 """ | 20 """ |
| 21 | 21 |
| 22 def __init__(self, executable_path, command_prefix=None): | 22 def __init__(self, executable_path, command_prefix=None): |
| 23 self.executable_path = executable_path | 23 self.executable_path = executable_path |
| 24 self.command_prefix = command_prefix if command_prefix else [] | 24 self.command_prefix = command_prefix if command_prefix else [] |
| 25 | 25 |
| 26 @overrides(Shell) | 26 @overrides(Shell) |
| 27 def serve_local_directory(self, local_dir_path, port=0): | 27 def serve_local_directory(self, local_dir_path, port=0): |
| 28 mappings = [('', local_dir_path)] | 28 mappings = [('', [local_dir_path])] |
| 29 return 'http://%s:%d/' % http_server.start_http_server(mappings, port) | 29 return 'http://%s:%d/' % http_server.start_http_server(mappings, port) |
| 30 | 30 |
| 31 @overrides(Shell) | 31 @overrides(Shell) |
| 32 def serve_local_directories(self, mappings, port=0): | 32 def serve_local_directories(self, mappings, port=0): |
| 33 return 'http://%s:%d/' % http_server.start_http_server(mappings, port) | 33 return 'http://%s:%d/' % http_server.start_http_server(mappings, port) |
| 34 | 34 |
| 35 @overrides(Shell) | 35 @overrides(Shell) |
| 36 def forward_host_port_to_shell(self, host_port): | 36 def forward_host_port_to_shell(self, host_port): |
| 37 pass | 37 pass |
| 38 | 38 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 57 (Results.output, _) = p.communicate() | 57 (Results.output, _) = p.communicate() |
| 58 | 58 |
| 59 run_thread = threading.Thread(target=do_run) | 59 run_thread = threading.Thread(target=do_run) |
| 60 run_thread.start() | 60 run_thread.start() |
| 61 run_thread.join(timeout) | 61 run_thread.join(timeout) |
| 62 | 62 |
| 63 if run_thread.is_alive(): | 63 if run_thread.is_alive(): |
| 64 p.terminate() | 64 p.terminate() |
| 65 return p.returncode, Results.output, True | 65 return p.returncode, Results.output, True |
| 66 return p.returncode, Results.output, False | 66 return p.returncode, Results.output, False |
| OLD | NEW |