OLD | NEW |
| (Empty) |
1 from twisted.web import html, resource | |
2 from buildbot.status.web.base import Box | |
3 from buildbot.status.web.base import HtmlResource | |
4 from buildbot.status.web.base import IBox | |
5 | |
6 class BuildStatusStatusResource(HtmlResource): | |
7 def __init__(self, categories=None): | |
8 HtmlResource.__init__(self) | |
9 | |
10 def head(self, request): | |
11 return "" | |
12 | |
13 def body(self, request): | |
14 """Display a build in the same format as the waterfall page. | |
15 The HTTP GET parameters are the builder name and the build | |
16 number.""" | |
17 | |
18 status = self.getStatus(request) | |
19 data = "" | |
20 | |
21 # Get the parameters. | |
22 name = request.args.get("builder", [None])[0] | |
23 number = request.args.get("number", [None])[0] | |
24 if not name or not number: | |
25 return "builder and number parameter missing" | |
26 number = int(number) | |
27 | |
28 # Main table for the build status. | |
29 data += '<table>\n' | |
30 | |
31 # Check if the builder in parameter exists. | |
32 try: | |
33 builder = status.getBuilder(name) | |
34 except: | |
35 return "unknown builder" | |
36 | |
37 # Check if the build in parameter exists. | |
38 build = builder.getBuild(int(number)) | |
39 if not build: | |
40 return "unknown build %s" % number | |
41 | |
42 # Display each step, starting by the last one. | |
43 for i in range(len(build.getSteps()) - 1, -1, -1): | |
44 step = build.getSteps()[i] | |
45 if step.isStarted() and step.getText(): | |
46 data += " <tr>\n" | |
47 data += IBox(step).getBox(request).td(align="center") | |
48 data += " </tr>\n" | |
49 | |
50 # Display the bottom box with the build number in it. | |
51 data += "<tr>" | |
52 data += IBox(build).getBox(request).td(align="center") | |
53 data += "</tr></table>\n" | |
54 | |
55 # We want all links to display in a new tab/window instead of in the | |
56 # current one. | |
57 data = data.replace('<a ', '<a target="_blank"') | |
58 return data | |
OLD | NEW |