This repository has been archived by the owner on May 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying to deliver build status images
- Loading branch information
Adam Groszer
committed
Feb 26, 2013
1 parent
42ca614
commit 8479c03
Showing
7 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.