| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 atexit | 5 import atexit |
| 6 import hashlib | 6 import hashlib |
| 7 import json | 7 import json |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import os.path | 10 import os.path |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 host_port = self._forward_host_port_to_device(0, device_port) | 401 host_port = self._forward_host_port_to_device(0, device_port) |
| 402 print ("Dart observatory available at the host at http://127.0.0.1:%d" | 402 print ("Dart observatory available at the host at http://127.0.0.1:%d" |
| 403 % host_port) | 403 % host_port) |
| 404 | 404 |
| 405 logcat_watch_thread = threading.Thread( | 405 logcat_watch_thread = threading.Thread( |
| 406 target=_forward_observatories_as_needed) | 406 target=_forward_observatories_as_needed) |
| 407 logcat_watch_thread.daemon = True | 407 logcat_watch_thread.daemon = True |
| 408 logcat_watch_thread.start() | 408 logcat_watch_thread.start() |
| 409 | 409 |
| 410 @overrides(Shell) | 410 @overrides(Shell) |
| 411 def serve_local_directory(self, local_dir_path, port=0): | 411 def serve_local_directory(self, local_dir_path, port=0, free_host_port=False): |
| 412 assert local_dir_path | 412 assert local_dir_path |
| 413 mappings = [('', [local_dir_path])] | 413 mappings = [('', [local_dir_path])] |
| 414 server_address = start_http_server(mappings, host_port=port) | 414 host_port = 0 if free_host_port else port |
| 415 server_address = start_http_server(mappings, host_port=host_port) |
| 415 | 416 |
| 416 return 'http://127.0.0.1:%d/' % self._forward_device_port_to_host( | 417 return 'http://127.0.0.1:%d/' % self._forward_device_port_to_host( |
| 417 port, server_address[1]) | 418 port, server_address[1]) |
| 418 | 419 |
| 419 @overrides(Shell) | 420 @overrides(Shell) |
| 420 def serve_local_directories(self, mappings, port=0): | 421 def serve_local_directories(self, mappings, port=0, free_host_port=False): |
| 421 assert mappings | 422 assert mappings |
| 422 server_address = start_http_server(mappings, host_port=port) | 423 host_port = 0 if free_host_port else port |
| 424 server_address = start_http_server(mappings, host_port=host_port) |
| 423 | 425 |
| 424 return 'http://127.0.0.1:%d/' % self._forward_device_port_to_host( | 426 return 'http://127.0.0.1:%d/' % self._forward_device_port_to_host( |
| 425 port, server_address[1]) | 427 port, server_address[1]) |
| 426 | 428 |
| 427 @overrides(Shell) | 429 @overrides(Shell) |
| 428 def forward_host_port_to_shell(self, host_port): | 430 def forward_host_port_to_shell(self, host_port): |
| 429 self._forward_host_port_to_device(host_port, host_port) | 431 self._forward_host_port_to_device(host_port, host_port) |
| 430 | 432 |
| 431 @overrides(Shell) | 433 @overrides(Shell) |
| 432 def run(self, arguments): | 434 def run(self, arguments): |
| (...skipping 23 matching lines...) Expand all Loading... |
| 456 Results.output = rf.read() | 458 Results.output = rf.read() |
| 457 | 459 |
| 458 run_thread = threading.Thread(target=do_run) | 460 run_thread = threading.Thread(target=do_run) |
| 459 run_thread.start() | 461 run_thread.start() |
| 460 run_thread.join(timeout) | 462 run_thread.join(timeout) |
| 461 | 463 |
| 462 if run_thread.is_alive(): | 464 if run_thread.is_alive(): |
| 463 self.stop_shell() | 465 self.stop_shell() |
| 464 return None, Results.output, True | 466 return None, Results.output, True |
| 465 return None, Results.output, False | 467 return None, Results.output, False |
| OLD | NEW |