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 default_rev_order = "asc"
185
186 - def content(self, request, cxt):
187 """This method builds the transposed grid display.
188 That is, build hosts across the top, build stamps down the left side
189 """
190
191
192 numBuilds = int(request.args.get("length", [5])[0])
193 categories = request.args.get("category", [])
194 branch = request.args.get("branch", [ANYBRANCH])[0]
195 if branch == 'trunk': branch = None
196
197 rev_order = request.args.get("rev_order", [self.default_rev_order])[0]
198 if rev_order not in ["asc", "desc"]:
199 rev_order = self.default_rev_order
200
201 cxt['refresh'] = self.get_reload_time(request)
202
203
204 status = self.getStatus(request)
205 stamps = self.getRecentSourcestamps(status, numBuilds, categories, branch)
206
207 cxt.update({'categories': categories,
208 'branch': branch,
209 'ANYBRANCH': ANYBRANCH,
210 'stamps': map(SourceStamp.asDict, stamps),
211 })
212
213 sortedBuilderNames = status.getBuilderNames()[:]
214 sortedBuilderNames.sort()
215
216 cxt['sorted_builder_names'] = sortedBuilderNames
217 cxt['builder_builds'] = builder_builds = []
218 cxt['builders'] = builders = []
219 cxt['range'] = range(len(stamps))
220 if rev_order == "desc":
221 cxt['range'].reverse()
222
223 for bn in sortedBuilderNames:
224 builds = [None] * len(stamps)
225
226 builder = status.getBuilder(bn)
227 if categories and builder.category not in categories:
228 continue
229
230 build = builder.getBuild(-1)
231 while build and None in builds:
232 ss = build.getSourceStamp(absolute=True)
233 key = self.getSourceStampKey(ss)
234 for i in range(len(stamps)):
235 if key == self.getSourceStampKey(stamps[i]) and builds[i] is None:
236 builds[i] = build
237 build = build.getPreviousBuild()
238
239 builders.append(self.builder_cxt(request, builder))
240 builder_builds.append(map(lambda b: self.build_cxt(request, b), builds))
241
242 template = request.site.buildbot_service.templates.get_template('grid_transposed.html')
243 data = template.render(**cxt)
244 return data
245