Commit 55dee9a0 authored by zty@chromium.org's avatar zty@chromium.org

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: svn://svn.chromium.org/chrome/trunk/src@282728 0039d316-1c4b-4281-b951-d872f2087c98
parent 0204b101
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# found in the LICENSE file. # found in the LICENSE file.
"""A class to keep track of devices across builds and report state.""" """A class to keep track of devices across builds and report state."""
import json
import logging import logging
import optparse import optparse
import os import os
...@@ -275,6 +276,8 @@ def main(): ...@@ -275,6 +276,8 @@ def main():
help='Output device status data for dashboard.') help='Output device status data for dashboard.')
parser.add_option('--restart-usb', action='store_true', parser.add_option('--restart-usb', action='store_true',
help='Restart USB ports before running device check.') 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() options, args = parser.parse_args()
if args: if args:
...@@ -359,6 +362,16 @@ def main(): ...@@ -359,6 +362,16 @@ def main():
[battery], '%', [battery], '%',
'unimportant') '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: if False in fail_step_lst:
# TODO(navabi): Build fails on device status check step if there exists any # TODO(navabi): Build fails on device status check step if there exists any
# devices with critically low battery. Remove those devices from testing, # devices with critically low battery. Remove those devices from testing,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment