OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import argparse | 6 import argparse |
7 import json | 7 import json |
8 import sys | 8 import sys |
9 import os | 9 import os |
10 | 10 |
11 tracing_path = os.path.abspath(os.path.join( | 11 tracing_path = os.path.abspath(os.path.join( |
12 os.path.dirname(os.path.realpath(__file__)), '..')) | 12 os.path.dirname(os.path.realpath(__file__)), '..')) |
13 sys.path.append(tracing_path) | 13 sys.path.append(tracing_path) |
14 from tracing import results_renderer | 14 from tracing import results_renderer |
15 | 15 |
16 | 16 |
17 def main(): | 17 def main(): |
18 parser = argparse.ArgumentParser( | 18 parser = argparse.ArgumentParser( |
19 description='Extract HistogramSet JSON from results2.html.', | 19 description='Extract HistogramSet JSON from results2.html.', |
20 add_help=False) | 20 add_help=False) |
21 parser.add_argument('html_path', metavar='HTML_PATH', | 21 parser.add_argument('html_path', metavar='HTML_PATH', |
22 help='HTML file path (input).') | 22 help='HTML file path (input).') |
23 parser.add_argument('json_path', metavar='JSON_PATH', | 23 parser.add_argument('json_path', metavar='JSON_PATH', |
24 help='JSON file path (input/output).') | 24 help='JSON file path (input/output).') |
25 parser.add_argument('-h', '--help', action='help', | 25 parser.add_argument('-h', '--help', action='help', |
26 help='Show this help message and exit.') | 26 help='Show this help message and exit.') |
27 args = parser.parse_args() | 27 args = parser.parse_args() |
28 | 28 |
29 histograms = results_renderer.ReadExistingResults(open(args.html_path, 'r')) | 29 histograms = results_renderer.ReadExistingResults( |
| 30 open(args.html_path, 'r').read()) |
30 if os.path.exists(args.json_path): | 31 if os.path.exists(args.json_path): |
31 histograms.extend(json.load(open(args.json_path, 'r'))) | 32 histograms.extend(json.load(open(args.json_path, 'r'))) |
32 json.dump(histograms, open(args.json_path, 'w')) | 33 json.dump(histograms, open(args.json_path, 'w')) |
33 | 34 |
34 if __name__ == '__main__': | 35 if __name__ == '__main__': |
35 sys.exit(main()) | 36 sys.exit(main()) |
OLD | NEW |