| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """A class to keep track of devices across builds and report state.""" | 7 """A class to keep track of devices across builds and report state.""" |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import json | 10 import json |
| 11 import logging | 11 import logging |
| 12 import os | 12 import os |
| 13 import psutil | 13 import psutil |
| 14 import re | 14 import re |
| 15 import signal | 15 import signal |
| 16 import sys | 16 import sys |
| 17 | 17 |
| 18 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | 18 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) |
| 19 import devil_chromium | 19 import devil_chromium |
| 20 from devil import devil_env | |
| 21 from devil.android import battery_utils | 20 from devil.android import battery_utils |
| 22 from devil.android import device_blacklist | 21 from devil.android import device_blacklist |
| 23 from devil.android import device_errors | 22 from devil.android import device_errors |
| 24 from devil.android import device_list | 23 from devil.android import device_list |
| 25 from devil.android import device_utils | 24 from devil.android import device_utils |
| 26 from devil.android.sdk import adb_wrapper | 25 from devil.android.sdk import adb_wrapper |
| 27 from devil.constants import exit_codes | 26 from devil.constants import exit_codes |
| 28 from devil.utils import lsusb | 27 from devil.utils import lsusb |
| 29 from devil.utils import reset_usb | 28 from devil.utils import reset_usb |
| 30 from devil.utils import run_tests_helper | 29 from devil.utils import run_tests_helper |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 parser.add_argument('--known-devices-file', action='append', default=[], | 315 parser.add_argument('--known-devices-file', action='append', default=[], |
| 317 dest='known_devices_files', | 316 dest='known_devices_files', |
| 318 help='Path to known device lists.') | 317 help='Path to known device lists.') |
| 319 parser.add_argument('-v', '--verbose', action='count', default=1, | 318 parser.add_argument('-v', '--verbose', action='count', default=1, |
| 320 help='Log more information.') | 319 help='Log more information.') |
| 321 | 320 |
| 322 args = parser.parse_args() | 321 args = parser.parse_args() |
| 323 | 322 |
| 324 run_tests_helper.SetLogLevel(args.verbose) | 323 run_tests_helper.SetLogLevel(args.verbose) |
| 325 | 324 |
| 326 devil_custom_deps = None | 325 devil_chromium.Initialize(adb_path=args.adb_path) |
| 327 if args.adb_path: | |
| 328 devil_custom_deps = { | |
| 329 'adb': { | |
| 330 devil_env.GetPlatform(): [args.adb_path], | |
| 331 }, | |
| 332 } | |
| 333 | |
| 334 devil_chromium.Initialize(custom_deps=devil_custom_deps) | |
| 335 | 326 |
| 336 blacklist = (device_blacklist.Blacklist(args.blacklist_file) | 327 blacklist = (device_blacklist.Blacklist(args.blacklist_file) |
| 337 if args.blacklist_file | 328 if args.blacklist_file |
| 338 else None) | 329 else None) |
| 339 | 330 |
| 340 last_devices_path = os.path.join( | 331 last_devices_path = os.path.join( |
| 341 args.out_dir, device_list.LAST_DEVICES_FILENAME) | 332 args.out_dir, device_list.LAST_DEVICES_FILENAME) |
| 342 args.known_devices_files.append(last_devices_path) | 333 args.known_devices_files.append(last_devices_path) |
| 343 | 334 |
| 344 expected_devices = set() | 335 expected_devices = set() |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 live_devices = [status['serial'] for status in statuses | 411 live_devices = [status['serial'] for status in statuses |
| 421 if (status['adb_status'] == 'device' | 412 if (status['adb_status'] == 'device' |
| 422 and not _IsBlacklisted(status['serial'], blacklist))] | 413 and not _IsBlacklisted(status['serial'], blacklist))] |
| 423 | 414 |
| 424 # If all devices failed, or if there are no devices, it's an infra error. | 415 # If all devices failed, or if there are no devices, it's an infra error. |
| 425 return 0 if live_devices else exit_codes.INFRA | 416 return 0 if live_devices else exit_codes.INFRA |
| 426 | 417 |
| 427 | 418 |
| 428 if __name__ == '__main__': | 419 if __name__ == '__main__': |
| 429 sys.exit(main()) | 420 sys.exit(main()) |
| OLD | NEW |