blob: cf94dd6500003e0449b49cc4a4f9dadc27fa242a [file] [log] [blame]
#!/usr/bin/env python2
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# pylint: disable=cros-logging-import
"""Script to re-format json result to one with branch_name and build_id"""
from __future__ import print_function
import argparse
import config
import json
import logging
import os
import subprocess
import sys
# Turn the logging level to INFO before importing other autotest
# code, to avoid having failed import logging messages confuse the
# test_droid user.
def _parse_arguments_internal(argv):
parser = argparse.ArgumentParser(description='Convert result to JSON'
'-b', '--bench', help='Generate JSON format file for which benchmark.')
return parser.parse_args(argv)
def fix_json(bench):
# Set environment variable for crosperf
os.environ['PYTHONPATH'] = os.path.dirname(config.toolchain_utils)'Generating Crosperf Report...')
json_path = os.path.join(config.bench_suite_dir, bench + '_refined')
crosperf_cmd = [
os.path.join(config.toolchain_utils, ''), '--json',
'-i=' + os.path.join(config.bench_suite_dir, bench + '.json'),
'-o=' + json_path, '-f'
# Run crosperf'Command: %s', crosperf_cmd)
json_path += '.json'
with open(json_path) as fout:
objs = json.load(fout)
for obj in objs:
obj['branch_name'] = 'aosp/master'
obj['build_id'] = 0
with open(json_path, 'w') as fout:
json.dump(objs, fout)'JSON file fixed successfully!')
def main(argv):
arguments = _parse_arguments_internal(argv)
bench = arguments.bench
if __name__ == '__main__':