| 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 | |
| 8 import logging | 7 import logging |
| 9 import os | 8 import os |
| 10 import os.path | 9 import os.path |
| 11 import random | 10 import random |
| 12 import re | 11 import re |
| 13 import subprocess | 12 import subprocess |
| 14 import sys | 13 import sys |
| 15 import tempfile | 14 import tempfile |
| 16 import threading | 15 import threading |
| 17 import time | 16 import time |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 if port not in opened: | 59 if port not in opened: |
| 61 return port | 60 return port |
| 62 else: | 61 else: |
| 63 raise Exception('Failed to identify an available port.') | 62 raise Exception('Failed to identify an available port.') |
| 64 | 63 |
| 65 | 64 |
| 66 def _find_available_host_port(): | 65 def _find_available_host_port(): |
| 67 netstat_output = subprocess.check_output(['netstat']) | 66 netstat_output = subprocess.check_output(['netstat']) |
| 68 return _find_available_port(netstat_output) | 67 return _find_available_port(netstat_output) |
| 69 | 68 |
| 69 |
| 70 def parse_adb_devices_output(adb_devices_output): | 70 def parse_adb_devices_output(adb_devices_output): |
| 71 """Parses the output of the `adb devices` command, returning a dictionary | 71 """Parses the output of the `adb devices` command, returning a dictionary |
| 72 mapping device id to the status of the device, as printed by `adb devices`. | 72 mapping device id to the status of the device, as printed by `adb devices`. |
| 73 """ | 73 """ |
| 74 # Split into lines skipping empty ones. | 74 # Split into lines skipping empty ones. |
| 75 lines = [line.strip() for line in adb_devices_output.split('\n') | 75 lines = [line.strip() for line in adb_devices_output.split('\n') |
| 76 if line.strip()] | 76 if line.strip()] |
| 77 | 77 |
| 78 if _ADB_DEVICES_HEADER not in lines: | 78 if _ADB_DEVICES_HEADER not in lines: |
| 79 return None | 79 return None |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 Results.output = rf.read() | 471 Results.output = rf.read() |
| 472 | 472 |
| 473 run_thread = threading.Thread(target=do_run) | 473 run_thread = threading.Thread(target=do_run) |
| 474 run_thread.start() | 474 run_thread.start() |
| 475 run_thread.join(timeout) | 475 run_thread.join(timeout) |
| 476 | 476 |
| 477 if run_thread.is_alive(): | 477 if run_thread.is_alive(): |
| 478 self.stop_shell() | 478 self.stop_shell() |
| 479 return None, Results.output, True | 479 return None, Results.output, True |
| 480 return None, Results.output, False | 480 return None, Results.output, False |
| OLD | NEW |