OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 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 """Functions for adding results to perf dashboard.""" |
| 7 |
| 8 import httplib |
| 9 import json |
| 10 import sys |
| 11 import urllib |
| 12 import urllib2 |
| 13 |
| 14 SEND_RESULTS_PATH = "/add_point" |
| 15 RESULTS_LINK_PATH = "/report?masters=%s&bots=%s&tests=%s&rev=%s" |
| 16 |
| 17 |
| 18 # TODO(sullivan): cache results to a file in case of http errors. |
| 19 def SendResults(logname, lines, master, system, test, url): |
| 20 results_to_add = [] |
| 21 bot = system |
| 22 if not logname.endswith("-summary.dat"): |
| 23 return |
| 24 graph = logname.replace("-summary.dat", "") |
| 25 for line in lines: |
| 26 data = json.loads(line) |
| 27 revision = data["rev"] |
| 28 for (trace, values) in data["traces"].iteritems(): |
| 29 # TODO(sullivan): Handle special trace names: |
| 30 # Reference builds |
| 31 # by_url builds |
| 32 test_path = "%s/%s/%s" % (test, graph, trace) |
| 33 if graph == trace: |
| 34 test_path = "%s/%s" % (test, graph) |
| 35 result = { |
| 36 "master": master, |
| 37 "bot": system, |
| 38 "test": test_path, |
| 39 "revision": revision, |
| 40 "value": values[0], |
| 41 "error": values[1], |
| 42 } |
| 43 if "webkit_rev" in data and data["webkit_rev"] != "undefined": |
| 44 result["supplemental_columns"] = {"r_webkit_rev": data["webkit_rev"]} |
| 45 results_to_add.append(result) |
| 46 data = urllib.urlencode({"data": json.dumps(results_to_add)}) |
| 47 req = urllib2.Request(url + SEND_RESULTS_PATH, data) |
| 48 # TODO(sullivan): properly handle exceptions. |
| 49 try: |
| 50 urllib2.urlopen(req) |
| 51 except urllib2.HTTPError, e: |
| 52 sys.stderr.write("HTTPError: %d\n" % e.code) |
| 53 except urllib2.URLError, e: |
| 54 sys.stderr.write("URLError: %s\n" % str(e.reason)) |
| 55 except httplib.HTTPException, e: |
| 56 sys.stderr.write("HTTPException\n") |
| 57 |
| 58 results_link = url + RESULTS_LINK_PATH % ( |
| 59 urllib.quote(master), |
| 60 urllib.quote(bot), |
| 61 urllib.quote(test + "/" + graph), |
| 62 revision) |
| 63 print "@@@STEP_LINK@%s@%s@@@" % ("Results Dashboard", results_link) |
OLD | NEW |