Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: appengine/chromium_cq_status/handlers/builder_timeline_data.py

Issue 2056663002: Removed timeline code (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Provides a JSON endpoint for builder data as Trace Viewer Events
6
7 Given a master, builder, and build ID, queries chrome-build-extract and
8 converts the resulting JSON to a format parseable by Trace Viewer.
9 """
10
11 import contextlib
12 import urllib2
13 import json
14 import webapp2
15
16 from shared.utils import cross_origin_json
17 from handlers.patch_timeline_data import (
18 TraceViewerEvent,
19 MetaEvent,
20 )
21
22 class BuilderTimelineData(webapp2.RequestHandler):
23 @cross_origin_json
24 def get(self, master, builder, buildId, attempt_string): # pragma: no cover
25 data = get_data(master, builder, buildId)
26 events = []
27 if data:
28 for event in create_events(data, master, builder, buildId,
29 attempt_string):
30 events.append(event.to_dict())
31 return events
32
33
34 def get_data(master, builder, buildId): # pragma: no cover
35 url = ('http://chrome-build-extract.appspot.com/p/' + master + '/builders/'
36 + builder + '/builds/' + buildId + '?json=1')
37 with contextlib.closing(urllib2.urlopen(url)) as response:
38 data = json.load(response)
39 # If the builder is running, chrome-build-extract returns {'error': '404'}
40 if data.get('error'):
41 return None
42 else:
43 return data
44
45
46 def create_events(data, master, builder, buildId,
47 attempt_string):
48 steps = data['steps']
49 state = 'cq_build_failed' if data.get('failed_steps') else 'cq_build_passed'
50 for step in steps:
51 cname = state if step['name'] == 'steps' else None
52 yield TraceViewerEvent(step['name'], master, 'B', step['times'][0],
53 attempt_string, builder, cname, {'id': buildId})
54 yield TraceViewerEvent(step['name'], master, 'E', step['times'][1],
55 attempt_string, builder, cname, {'id': buildId})
OLDNEW
« no previous file with comments | « appengine/chromium_cq_status/README ('k') | appengine/chromium_cq_status/handlers/patch_timeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698