1 from __future__ import generators
2
3 from buildbot.status.web.base import HtmlResource
4 from buildbot.status.web.base import build_get_class, path_to_builder, path_to_build
5 from buildbot.sourcestamp import SourceStamp
6
8
17
18
19
21 if "reload" in request.args:
22 try:
23 reload_time = int(request.args["reload"][0])
24 return max(reload_time, 15)
25 except ValueError:
26 pass
27 return None
28
49
77
79 """Given two source stamps, we want to assign them to the same row if
80 they are the same version of code, even if they differ in minor detail.
81
82 This function returns an appropriate comparison key for that.
83 """
84 return (ss.branch, ss.revision, ss.patch)
85
120
122
123 status = None
124 changemaster = None
125
126 - def content(self, request, cxt):
127 """This method builds the regular grid display.
128 That is, build stamps across the top, build hosts down the left side
129 """
130
131
132 numBuilds = int(request.args.get("width", [5])[0])
133 categories = request.args.get("category", [])
134 branch = request.args.get("branch", [ANYBRANCH])[0]
135 if branch == 'trunk': branch = None
136
137
138 status = self.getStatus(request)
139 stamps = self.getRecentSourcestamps(status, numBuilds, categories, branch)
140
141 cxt['refresh'] = self.get_reload_time(request)
142
143 cxt.update({'categories': categories,
144 'branch': branch,
145 'ANYBRANCH': ANYBRANCH,
146 'stamps': map(SourceStamp.asDict, stamps)
147 })
148
149 sortedBuilderNames = status.getBuilderNames()[:]
150 sortedBuilderNames.sort()
151
152 cxt['builders'] = []
153
154 for bn in sortedBuilderNames:
155 builds = [None] * len(stamps)
156
157 builder = status.getBuilder(bn)
158 if categories and builder.category not in categories:
159 continue
160
161 build = builder.getBuild(-1)
162 while build and None in builds:
163 ss = build.getSourceStamp(absolute=True)
164 key= self.getSourceStampKey(ss)
165 for i in range(len(stamps)):
166 if key == self.getSourceStampKey(stamps[i]) and builds[i] is None:
167 builds[i] = build
168 build = build.getPreviousBuild()
169
170 b = self.builder_cxt(request, builder)
171 b['builds'] = []
172 for build in builds:
173 b['builds'].append(self.build_cxt(request, build))
174 cxt['builders'].append(b)
175
176 template = request.site.buildbot_service.templates.get_template("grid.html")
177 return template.render(**cxt)
178
179
181
182 status = None
183 changemaster = None
184
185 - def content(self, request, cxt):
186 """This method builds the transposed grid display.
187 That is, build hosts across the top, build stamps down the left side
188 """
189
190
191 numBuilds = int(request.args.get("length", [5])[0])
192 categories = request.args.get("category", [])
193 branch = request.args.get("branch", [ANYBRANCH])[0]
194 if branch == 'trunk': branch = None
195
196 cxt['refresh'] = self.get_reload_time(request)
197
198
199 status = self.getStatus(request)
200 stamps = self.getRecentSourcestamps(status, numBuilds, categories, branch)
201
202 cxt.update({'categories': categories,
203 'branch': branch,
204 'ANYBRANCH': ANYBRANCH,
205 'stamps': map(SourceStamp.asDict, stamps),
206 })
207
208 sortedBuilderNames = status.getBuilderNames()[:]
209 sortedBuilderNames.sort()
210
211 cxt['sorted_builder_names'] = sortedBuilderNames
212 cxt['builder_builds'] = builder_builds = []
213 cxt['builders'] = builders = []
214 cxt['range'] = range(len(stamps))
215
216 for bn in sortedBuilderNames:
217 builds = [None] * len(stamps)
218
219 builder = status.getBuilder(bn)
220 if categories and builder.category not in categories:
221 continue
222
223 build = builder.getBuild(-1)
224 while build and None in builds:
225 ss = build.getSourceStamp(absolute=True)
226 key = self.getSourceStampKey(ss)
227 for i in range(len(stamps)):
228 if key == self.getSourceStampKey(stamps[i]) and builds[i] is None:
229 builds[i] = build
230 build = build.getPreviousBuild()
231
232 builders.append(self.builder_cxt(request, builder))
233 builder_builds.append(map(lambda b: self.build_cxt(request, b), builds))
234
235 template = request.site.buildbot_service.templates.get_template('grid_transposed.html')
236 data = template.render(**cxt)
237 return data
238