Skip to content

Instantly share code, notes, and snippets.

@ampz9
Created March 23, 2017 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ampz9/ea1f70ad17f11f4308bb8e54053a671d to your computer and use it in GitHub Desktop.
Save ampz9/ea1f70ad17f11f4308bb8e54053a671d to your computer and use it in GitHub Desktop.
python portion to create grid dashboard
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)
# 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
try:
if build["properties"]["got_revision"][0] not in revisions:
revisions.append(build["properties"]["got_revision"][0])
except KeyError:
# 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...
pass
# would like to display newest first
revisions.sort(reverse=True)
# 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'] = [ # This is a list of dashboards, you can create several
{
'name': 'grid', # as used in URLs
'caption': 'Grid', # Title displayed in the UI'
'app': griddashboardapp,
'order': 5, # priority of the dashboard in the left menu (lower is higher in the menu)
'icon': 'table' # available icon list can be found at http://fontawesome.io/icons/
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment