forked from MariaDB/buildbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid.py
65 lines (52 loc) · 2.59 KB
/
grid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from __future__ import absolute_import
from __future__ import print_function
import os
from buildbot.process.results import statusToString
from flask import Flask
from flask import render_template
griddashboardapp = Flask('grid', root_path=os.path.dirname(__file__))
# this allows to work on the template without having to restart Buildbot
griddashboardapp.config['TEMPLATES_AUTO_RELOAD'] = True
@griddashboardapp.route("/index.html")
def main():
# This code fetches build data from the data api, and give it to the template
builders = griddashboardapp.buildbot_api.dataGet("/builders")
# request last 20 builds
builds = griddashboardapp.buildbot_api.dataGet("/builds", order=["-buildid"], limit=20)
used_builders = list(map(lambda x: x['builderid'], builds))
builders = list(filter(lambda x: x['builderid'] in used_builders, builders))
# to store all revisions from builds above
revisions = []
# properties are actually not used in the template example, but this is how you get more properties
for build in builds:
build['properties'] = griddashboardapp.buildbot_api.dataGet(("builds", build['buildid'], "properties"))
build['results_text'] = statusToString(build['results']) # translate result to string
build['state'] = griddashboardapp.buildbot_api.dataGet(
("builds", build['buildid']))
try:
if build["properties"]["revision"][0] not in revisions:
revisions.append(build["properties"]["revision"][0])
except KeyError as e:
# this means the build didn't get to the point of getting a revision,
# more than likely an environment isssue such as disk full, power outtage, etc...
print('Error', str(e))
pass
# would like to display newest first
revisions.sort(reverse=True)
print(revisions, builds)
# grid.html is a template inside the template directory
return render_template('grid.html', builders=builders, builds=builds,
revisions=revisions)
# Here we assume c['www']['plugins'] has already be created earlier.
# Please see the web server documentation to understand how to configure
# the other parts.
c['www']['plugins']['wsgi_dashboards'].append({
'name': 'custom', # as used in URLs
'caption': 'Custom', # Title displayed in the UI'
'app': griddashboardapp,
# priority of the dashboard in the left menu (lower is higher in the
# menu)
'order': 15,
# available icon list can be found at http://fontawesome.io/icons/
'icon': 'share-alt-square'
})