Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
trying to deliver build status images
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Groszer committed Feb 26, 2013
1 parent f05f497 commit e3b6d43
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 1 deletion.
60 changes: 60 additions & 0 deletions image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# this is a snippet ready to be pasted into master.cfg
# then you can get the image by:
# http://localhost:8010/buildstatusimage?builder=runtests&number=-1

import os
from buildbot.status import html
from buildbot.status.results import SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION
from buildbot.status.results import Results
from buildbot.status.web.base import HtmlResource

class BuildStatusImageResource(HtmlResource):
contentType = "image/png"

def __init__(self, categories=None):
HtmlResource.__init__(self)

def content(self, request, ctx):
"""Display a build status image like Travis does."""

status = self.getStatus(request)
request.setHeader('Cache-Control', 'no-cache')

# Get the parameters.
name = request.args.get("builder", [None])[0]
number = request.args.get("number", [None])[0]
if not name or not number:
return "builder and number parameter missing"
number = int(number)

# Check if the builder in parameter exists.
try:
builder = status.getBuilder(name)
except:
return "unknown builder"

# Check if the build in parameter exists.
build = builder.getBuild(int(number))
if not build:
return "unknown build %s" % number

#SUCCESS, WARNINGS, FAILURE, SKIPPED or EXCEPTION
res = build.getResults()
resname = Results[res]

img = 'status_image_%s.png' % resname
here = os.path.dirname(__file__)
imgfile = os.path.join(here, img)

imgcontent = open(imgfile, 'rb').read()

return imgcontent

class WebStatus(html.WebStatus):
def setupUsualPages(self, numbuilds, num_events, num_events_max):
html.WebStatus.setupUsualPages(self, numbuilds, num_events, num_events_max)
self.putChild("buildstatusimage", BuildStatusImageResource())


# and use the WebStatus defined above instead of buildbot's
#c['status'].append(WebStatus(http_port=8010))
5 changes: 4 additions & 1 deletion master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ from buildbot.status import html
from buildbot.scheduler import Scheduler, Nightly, Triggerable, Periodic
from buildbot.steps.trigger import Trigger

import image

is_win32 = sys.platform == 'win32'

# This is a sample buildmaster config file. It must be installed as
Expand Down Expand Up @@ -1360,7 +1362,8 @@ bsquare_configure(c,
c['status'].append(html.WebStatus(http_port=8009, allowForce=True, logRotateLength=100000000))

#proxy THIS via apache
c['status'].append(html.WebStatus(http_port=8010, allowForce=False, logRotateLength=100000000))
#use the WebStatus that provides status images
c['status'].append(image.WebStatus(http_port=8010, allowForce=False, logRotateLength=100000000))


c['projectName'] = "Zope wineggbuilder and windows buildbot"
Expand Down
Binary file added status_image_exception.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added status_image_failure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added status_image_skipped.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added status_image_success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added status_image_warnings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e3b6d43

Please sign in to comment.