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 json | 8 import json |
9 import logging | 9 import logging |
10 import optparse | 10 import optparse |
(...skipping 319 matching lines...) Loading... |
330 offline_devices = android_commands.GetAttachedDevices( | 330 offline_devices = android_commands.GetAttachedDevices( |
331 hardware=False, emulator=False, offline=True) | 331 hardware=False, emulator=False, offline=True) |
332 | 332 |
333 types, builds, batteries, reports, errors, json_data = [], [], [], [], [], [] | 333 types, builds, batteries, reports, errors, json_data = [], [], [], [], [], [] |
334 fail_step_lst = [] | 334 fail_step_lst = [] |
335 if devices: | 335 if devices: |
336 types, builds, batteries, reports, errors, fail_step_lst, json_data = ( | 336 types, builds, batteries, reports, errors, fail_step_lst, json_data = ( |
337 zip(*[DeviceInfo(dev, options) for dev in devices])) | 337 zip(*[DeviceInfo(dev, options) for dev in devices])) |
338 | 338 |
339 # Write device info to file for buildbot info display. | 339 # Write device info to file for buildbot info display. |
340 with open('/home/chrome-bot/.adb_device_info', 'w') as f: | 340 if os.path.exists('/home/chrome-bot'): |
341 for device in json_data: | 341 with open('/home/chrome-bot/.adb_device_info', 'w') as f: |
342 f.write('%s %s %s %.1fC %s%%\n' % (device['serial'], device['type'], | 342 for device in json_data: |
343 device['build'], float(device['battery']['temperature']) / 10, | 343 f.write('%s %s %s %.1fC %s%%\n' % (device['serial'], device['type'], |
344 device['battery']['level'])) | 344 device['build'], float(device['battery']['temperature']) / 10, |
| 345 device['battery']['level'])) |
345 | 346 |
346 err_msg = CheckForMissingDevices(options, devices) or [] | 347 err_msg = CheckForMissingDevices(options, devices) or [] |
347 | 348 |
348 unique_types = list(set(types)) | 349 unique_types = list(set(types)) |
349 unique_builds = list(set(builds)) | 350 unique_builds = list(set(builds)) |
350 | 351 |
351 bb_annotations.PrintMsg('Online devices: %d. Device types %s, builds %s' | 352 bb_annotations.PrintMsg('Online devices: %d. Device types %s, builds %s' |
352 % (len(devices), unique_types, unique_builds)) | 353 % (len(devices), unique_types, unique_builds)) |
353 print '\n'.join(reports) | 354 print '\n'.join(reports) |
354 | 355 |
(...skipping 36 matching lines...) Loading... |
391 | 392 |
392 if num_failed_devs == len(devices): | 393 if num_failed_devs == len(devices): |
393 return 2 | 394 return 2 |
394 | 395 |
395 if not devices: | 396 if not devices: |
396 return 1 | 397 return 1 |
397 | 398 |
398 | 399 |
399 if __name__ == '__main__': | 400 if __name__ == '__main__': |
400 sys.exit(main()) | 401 sys.exit(main()) |
OLD | NEW |