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 import argparse | 8 import argparse |
9 import json | 9 import json |
10 import logging | 10 import logging |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 parser.add_argument('--json-output', | 288 parser.add_argument('--json-output', |
289 help='Output JSON information into a specified file.') | 289 help='Output JSON information into a specified file.') |
290 parser.add_argument('--blacklist-file', help='Device blacklist JSON file.') | 290 parser.add_argument('--blacklist-file', help='Device blacklist JSON file.') |
291 parser.add_argument('-v', '--verbose', action='count', default=1, | 291 parser.add_argument('-v', '--verbose', action='count', default=1, |
292 help='Log more information.') | 292 help='Log more information.') |
293 | 293 |
294 args = parser.parse_args() | 294 args = parser.parse_args() |
295 | 295 |
296 run_tests_helper.SetLogLevel(args.verbose) | 296 run_tests_helper.SetLogLevel(args.verbose) |
297 | 297 |
298 if args.blacklist_file: | 298 blacklist = (device_blacklist.Blacklist(args.blacklist_file) |
299 blacklist = device_blacklist.Blacklist(args.blacklist_file) | 299 if args.blacklist_file |
300 else: | 300 else None) |
301 # TODO(jbudorick): Remove this once bots pass the blacklist file. | |
302 blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON) | |
303 | 301 |
304 last_devices_path = os.path.join( | 302 last_devices_path = os.path.join( |
305 args.out_dir, device_list.LAST_DEVICES_FILENAME) | 303 args.out_dir, device_list.LAST_DEVICES_FILENAME) |
306 try: | 304 try: |
307 expected_devices = set( | 305 expected_devices = set( |
308 device_list.GetPersistentDeviceList(last_devices_path)) | 306 device_list.GetPersistentDeviceList(last_devices_path)) |
309 except IOError: | 307 except IOError: |
310 expected_devices = set() | 308 expected_devices = set() |
311 | 309 |
312 usb_devices = set(lsusb.get_android_devices()) | 310 usb_devices = set(lsusb.get_android_devices()) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 live_devices = [status['serial'] for status in statuses | 370 live_devices = [status['serial'] for status in statuses |
373 if (status['adb_status'] == 'device' | 371 if (status['adb_status'] == 'device' |
374 and status['serial'] not in blacklist.Read())] | 372 and status['serial'] not in blacklist.Read())] |
375 | 373 |
376 # If all devices failed, or if there are no devices, it's an infra error. | 374 # If all devices failed, or if there are no devices, it's an infra error. |
377 return 0 if live_devices else constants.INFRA_EXIT_CODE | 375 return 0 if live_devices else constants.INFRA_EXIT_CODE |
378 | 376 |
379 | 377 |
380 if __name__ == '__main__': | 378 if __name__ == '__main__': |
381 sys.exit(main()) | 379 sys.exit(main()) |
OLD | NEW |