OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Updates GpuDriverBugWorkaroundEntry enum in histograms.xml file with values |
| 7 read from gpu_driver_bug_list.json. |
| 8 |
| 9 If the file was pretty-printed, the updated version is pretty-printed too. |
| 10 """ |
| 11 |
| 12 import os.path |
| 13 import re |
| 14 import sys |
| 15 |
| 16 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) |
| 17 import path_util |
| 18 import json |
| 19 |
| 20 import update_histogram_enum |
| 21 |
| 22 |
| 23 GPU_DRIVER_BUG_WORKAROUND_PATH = 'gpu/config/gpu_driver_bug_list.json' |
| 24 |
| 25 |
| 26 def ReadGpuDriverBugEntries(filename): |
| 27 """Reads in the gpu driver bug list, returning a dictionary mapping |
| 28 workaround ids to descriptions. |
| 29 """ |
| 30 # Read the file as a list of lines |
| 31 with open(path_util.GetInputFile(filename)) as f: |
| 32 json_data = json.load(f) |
| 33 |
| 34 entries = {} |
| 35 entries[0] = '0: Recorded once every time this histogram is updated.' |
| 36 for entry in json_data["entries"]: |
| 37 entries[entry["id"]] = "%d: %s" % (entry["id"], entry["description"]) |
| 38 return entries |
| 39 |
| 40 |
| 41 def main(): |
| 42 if len(sys.argv) > 1: |
| 43 print >>sys.stderr, 'No arguments expected!' |
| 44 sys.stderr.write(__doc__) |
| 45 sys.exit(1) |
| 46 |
| 47 update_histogram_enum.UpdateHistogramFromDict( |
| 48 'GpuDriverBugWorkaroundEntry', |
| 49 ReadGpuDriverBugEntries(GPU_DRIVER_BUG_WORKAROUND_PATH), |
| 50 GPU_DRIVER_BUG_WORKAROUND_PATH) |
| 51 |
| 52 |
| 53 if __name__ == '__main__': |
| 54 main() |
OLD | NEW |