Chromium Code Reviews| Index: tools/metrics/histograms/update_gpu_driver_bug_workaround_entries.py |
| diff --git a/tools/metrics/histograms/update_gpu_driver_bug_workaround_entries.py b/tools/metrics/histograms/update_gpu_driver_bug_workaround_entries.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1c5446ec604bd36745455969ac2f7fe07445af77 |
| --- /dev/null |
| +++ b/tools/metrics/histograms/update_gpu_driver_bug_workaround_entries.py |
| @@ -0,0 +1,50 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2017 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Updates GpuDriverBugWorkaroundEntry enum in histograms.xml file with values |
| + read from gpu_driver_bug_list.json. |
| + |
| +If the file was pretty-printed, the updated version is pretty-printed too. |
| +""" |
| + |
| +import os.path |
| +import re |
| +import sys |
| + |
| +sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) |
| +import path_util |
| +import json |
| + |
| +import update_histogram_enum |
| + |
|
Ilya Sherman
2017/05/04 22:48:37
nit: Please leave an extra blank line here.
|
| +GPU_DRIVER_BUG_WORKAROUND_PATH = 'gpu/config/gpu_driver_bug_list.json' |
| + |
|
Ilya Sherman
2017/05/04 22:48:37
nit: Please leave an extra blank line here.
|
| +def ReadGpuDriverBugEntries(filename): |
| + """Reads in the gpu driver bug list, returning a dictionary mapping |
| + workaround ids to descriptions. |
| + """ |
| + # Read the file as a list of lines |
| + with open(path_util.GetInputFile(filename)) as f: |
| + json_data = json.load(f) |
| + |
| + entries = {} |
| + for entry in json_data["entries"]: |
| + entries[entry["id"]] = "%d: %s" % (entry["id"], entry["description"]) |
| + return entries |
| + |
| + |
| +def main(): |
| + if len(sys.argv) > 1: |
| + print >>sys.stderr, 'No arguments expected!' |
| + sys.stderr.write(__doc__) |
| + sys.exit(1) |
| + |
| + update_histogram_enum.UpdateHistogramFromDict( |
| + 'GpuDriverBugWorkaroundEntry', |
| + ReadGpuDriverBugEntries(GPU_DRIVER_BUG_WORKAROUND_PATH), |
| + GPU_DRIVER_BUG_WORKAROUND_PATH) |
| + |
|
Ilya Sherman
2017/05/04 22:48:36
nit: Please leave an extra blank line here.
|
| +if __name__ == '__main__': |
| + main() |