| 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 logging | 8 import logging |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 sys.path.append(os.path.join(os.path.dirname(__file__), | 23 sys.path.append(os.path.join(os.path.dirname(__file__), |
| 24 os.pardir, os.pardir, 'util', 'lib', | 24 os.pardir, os.pardir, 'util', 'lib', |
| 25 'common')) | 25 'common')) |
| 26 import perf_tests_results_helper # pylint: disable=F0401 | 26 import perf_tests_results_helper # pylint: disable=F0401 |
| 27 | 27 |
| 28 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 28 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 29 from pylib import android_commands | 29 from pylib import android_commands |
| 30 from pylib import constants | 30 from pylib import constants |
| 31 from pylib.cmd_helper import GetCmdOutput | 31 from pylib.cmd_helper import GetCmdOutput |
| 32 | 32 from pylib.device import device_blacklist |
| 33 | 33 |
| 34 def DeviceInfo(serial, options): | 34 def DeviceInfo(serial, options): |
| 35 """Gathers info on a device via various adb calls. | 35 """Gathers info on a device via various adb calls. |
| 36 | 36 |
| 37 Args: | 37 Args: |
| 38 serial: The serial of the attached device to construct info about. | 38 serial: The serial of the attached device to construct info about. |
| 39 | 39 |
| 40 Returns: | 40 Returns: |
| 41 Tuple of device type, build id, report as a string, error messages, and | 41 Tuple of device type, build id, report as a string, error messages, and |
| 42 boolean indicating whether or not device can be used for testing. | 42 boolean indicating whether or not device can be used for testing. |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 parser.add_option('--no-provisioning-check', action='store_true', | 268 parser.add_option('--no-provisioning-check', action='store_true', |
| 269 help='Will not check if devices are provisioned properly.') | 269 help='Will not check if devices are provisioned properly.') |
| 270 parser.add_option('--device-status-dashboard', action='store_true', | 270 parser.add_option('--device-status-dashboard', action='store_true', |
| 271 help='Output device status data for dashboard.') | 271 help='Output device status data for dashboard.') |
| 272 parser.add_option('--restart-usb', action='store_true', | 272 parser.add_option('--restart-usb', action='store_true', |
| 273 help='Restart USB ports before running device check.') | 273 help='Restart USB ports before running device check.') |
| 274 options, args = parser.parse_args() | 274 options, args = parser.parse_args() |
| 275 if args: | 275 if args: |
| 276 parser.error('Unknown options %s' % args) | 276 parser.error('Unknown options %s' % args) |
| 277 | 277 |
| 278 # Remove the last builds "bad devices" before checking device statuses. | 278 # Remove the last build's "bad devices" before checking device statuses. |
| 279 android_commands.ResetBadDevices() | 279 device_blacklist.ResetBlacklist() |
| 280 | 280 |
| 281 if options.restart_usb: | 281 if options.restart_usb: |
| 282 expected_devices = GetLastDevices(os.path.abspath(options.out_dir)) | 282 expected_devices = GetLastDevices(os.path.abspath(options.out_dir)) |
| 283 devices = android_commands.GetAttachedDevices() | 283 devices = android_commands.GetAttachedDevices() |
| 284 # Only restart usb if devices are missing. | 284 # Only restart usb if devices are missing. |
| 285 if set(expected_devices) != set(devices): | 285 if set(expected_devices) != set(devices): |
| 286 KillAllAdb() | 286 KillAllAdb() |
| 287 retries = 5 | 287 retries = 5 |
| 288 usb_restarted = True | 288 usb_restarted = True |
| 289 if not RestartUsb(): | 289 if not RestartUsb(): |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 # devices with critically low battery. Remove those devices from testing, | 350 # devices with critically low battery. Remove those devices from testing, |
| 351 # allowing build to continue with good devices. | 351 # allowing build to continue with good devices. |
| 352 return 1 | 352 return 1 |
| 353 | 353 |
| 354 if not devices: | 354 if not devices: |
| 355 return 1 | 355 return 1 |
| 356 | 356 |
| 357 | 357 |
| 358 if __name__ == '__main__': | 358 if __name__ == '__main__': |
| 359 sys.exit(main()) | 359 sys.exit(main()) |
| OLD | NEW |