Add option to output device status to a JSON file.

BUG=392938
R=navabi@chromium.org, tonyg@chromium.org

Review URL: https://codereview.chromium.org/383933003

git-svn-id: http://src.chromium.org/svn/trunk/src/build@282728 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
zty@chromium.org 2014-07-11 23:20:43 +00:00
Родитель 406ebe99a2
Коммит d6f56c1bb1
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -5,6 +5,7 @@
# found in the LICENSE file.
"""A class to keep track of devices across builds and report state."""
import json
import logging
import optparse
import os
@ -275,6 +276,8 @@ def main():
help='Output device status data for dashboard.')
parser.add_option('--restart-usb', action='store_true',
help='Restart USB ports before running device check.')
parser.add_option('--json-output',
help='Output JSON information into a specified file.')
options, args = parser.parse_args()
if args:
@ -359,6 +362,16 @@ def main():
[battery], '%',
'unimportant')
if options.json_output:
with open(options.json_output, 'wb') as f:
f.write(json.dumps({
'online_devices': devices,
'offline_devices': offline_devices,
'expected_devices': expected_devices,
'unique_types': unique_types,
'unique_builds': unique_builds,
}))
if False in fail_step_lst:
# TODO(navabi): Build fails on device status check step if there exists any
# devices with critically low battery. Remove those devices from testing,