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 logging | 9 import logging |
9 import optparse | 10 import optparse |
10 import os | 11 import os |
11 import psutil | 12 import psutil |
12 import re | 13 import re |
13 import signal | 14 import signal |
14 import smtplib | 15 import smtplib |
15 import subprocess | 16 import subprocess |
16 import sys | 17 import sys |
17 import time | 18 import time |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 parser = optparse.OptionParser() | 269 parser = optparse.OptionParser() |
269 parser.add_option('', '--out-dir', | 270 parser.add_option('', '--out-dir', |
270 help='Directory where the device path is stored', | 271 help='Directory where the device path is stored', |
271 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out')) | 272 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out')) |
272 parser.add_option('--no-provisioning-check', action='store_true', | 273 parser.add_option('--no-provisioning-check', action='store_true', |
273 help='Will not check if devices are provisioned properly.') | 274 help='Will not check if devices are provisioned properly.') |
274 parser.add_option('--device-status-dashboard', action='store_true', | 275 parser.add_option('--device-status-dashboard', action='store_true', |
275 help='Output device status data for dashboard.') | 276 help='Output device status data for dashboard.') |
276 parser.add_option('--restart-usb', action='store_true', | 277 parser.add_option('--restart-usb', action='store_true', |
277 help='Restart USB ports before running device check.') | 278 help='Restart USB ports before running device check.') |
279 parser.add_option('--json-output', | |
280 help='Output JSON information into a specified file.') | |
tonyg
2014/07/11 02:19:15
We should document the format somewhere.
| |
278 | 281 |
279 options, args = parser.parse_args() | 282 options, args = parser.parse_args() |
280 if args: | 283 if args: |
281 parser.error('Unknown options %s' % args) | 284 parser.error('Unknown options %s' % args) |
282 | 285 |
283 # Remove the last build's "bad devices" before checking device statuses. | 286 # Remove the last build's "bad devices" before checking device statuses. |
284 device_blacklist.ResetBlacklist() | 287 device_blacklist.ResetBlacklist() |
285 | 288 |
286 try: | 289 try: |
287 expected_devices = device_list.GetPersistentDeviceList( | 290 expected_devices = device_list.GetPersistentDeviceList( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 perf_tests_results_helper.PrintPerfResult('BotDevices', 'OnlineDevices', | 355 perf_tests_results_helper.PrintPerfResult('BotDevices', 'OnlineDevices', |
353 [len(devices)], 'devices') | 356 [len(devices)], 'devices') |
354 perf_tests_results_helper.PrintPerfResult('BotDevices', 'OfflineDevices', | 357 perf_tests_results_helper.PrintPerfResult('BotDevices', 'OfflineDevices', |
355 [len(offline_devices)], 'devices', | 358 [len(offline_devices)], 'devices', |
356 'unimportant') | 359 'unimportant') |
357 for serial, battery in zip(devices, batteries): | 360 for serial, battery in zip(devices, batteries): |
358 perf_tests_results_helper.PrintPerfResult('DeviceBattery', serial, | 361 perf_tests_results_helper.PrintPerfResult('DeviceBattery', serial, |
359 [battery], '%', | 362 [battery], '%', |
360 'unimportant') | 363 'unimportant') |
361 | 364 |
365 if options.json_output: | |
366 with open(options.json_output, 'wb') as f: | |
367 f.write(json.dumps({ | |
368 'online_devices': devices, | |
tonyg
2014/07/11 02:19:15
Let's add expected_devices too.
Also, prior to re
zty
2014/07/11 18:58:30
Acknowledged.
| |
369 'offline_devices': offline_devices | |
370 })) | |
371 | |
362 if False in fail_step_lst: | 372 if False in fail_step_lst: |
363 # TODO(navabi): Build fails on device status check step if there exists any | 373 # TODO(navabi): Build fails on device status check step if there exists any |
364 # devices with critically low battery. Remove those devices from testing, | 374 # devices with critically low battery. Remove those devices from testing, |
365 # allowing build to continue with good devices. | 375 # allowing build to continue with good devices. |
366 return 2 | 376 return 2 |
367 | 377 |
368 if not devices: | 378 if not devices: |
369 return 1 | 379 return 1 |
370 | 380 |
371 | 381 |
372 if __name__ == '__main__': | 382 if __name__ == '__main__': |
373 sys.exit(main()) | 383 sys.exit(main()) |
OLD | NEW |