1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 from twisted.web import html
18 from twisted.internet import defer, reactor
19 from twisted.web.util import Redirect, DeferredResource
20
21 import urllib, time
22 from twisted.python import log
23 from buildbot.status.web.base import HtmlResource, \
24 css_classes, path_to_build, path_to_builder, path_to_slave, \
25 getAndCheckProperties, ActionResource, path_to_authzfail, \
26 getRequestCharset
27 from buildbot.schedulers.forcesched import ForceScheduler, TextParameter
28 from buildbot.status.web.step import StepsResource
29 from buildbot.status.web.tests import TestsResource
30 from buildbot import util, interfaces
33
34 - def __init__(self, build_status, builder):
38
39 @defer.inlineCallbacks
86
89
93
94 @defer.inlineCallbacks
121
124 addSlash = True
125
129
130 - def getPageTitle(self, request):
131 return ("Buildbot: %s Build #%d" %
132 (self.build_status.getBuilder().getName(),
133 self.build_status.getNumber()))
134
135 - def content(self, req, cxt):
136 b = self.build_status
137 status = self.getStatus(req)
138 req.setHeader('Cache-Control', 'no-cache')
139
140 cxt['b'] = b
141 cxt['path_to_builder'] = path_to_builder(req, b.getBuilder())
142
143 if not b.isFinished():
144 step = b.getCurrentStep()
145 if not step:
146 cxt['current_step'] = "[waiting for Lock]"
147 else:
148 if step.isWaitingForLocks():
149 cxt['current_step'] = "%s [waiting for Lock]" % step.getName()
150 else:
151 cxt['current_step'] = step.getName()
152 when = b.getETA()
153 if when is not None:
154 cxt['when'] = util.formatInterval(when)
155 cxt['when_time'] = time.strftime("%H:%M:%S",
156 time.localtime(time.time() + when))
157
158 else:
159 cxt['result_css'] = css_classes[b.getResults()]
160 if b.getTestResults():
161 cxt['tests_link'] = req.childLink("tests")
162
163 ssList = b.getSourceStamps()
164 sourcestamps = cxt['sourcestamps'] = ssList
165
166 all_got_revisions = b.getAllGotRevisions()
167 cxt['got_revisions'] = all_got_revisions
168
169 try:
170 cxt['slave_url'] = path_to_slave(req, status.getSlave(b.getSlavename()))
171 except KeyError:
172 pass
173
174 cxt['steps'] = []
175
176 for s in b.getSteps():
177 step = {'name': s.getName() }
178
179 if s.isFinished():
180 if s.isHidden():
181 continue
182
183 step['css_class'] = css_classes[s.getResults()[0]]
184 (start, end) = s.getTimes()
185 step['time_to_run'] = util.formatInterval(end - start)
186 elif s.isStarted():
187 if s.isWaitingForLocks():
188 step['css_class'] = "waiting"
189 step['time_to_run'] = "waiting for locks"
190 else:
191 step['css_class'] = "running"
192 step['time_to_run'] = "running"
193 else:
194 step['css_class'] = "not_started"
195 step['time_to_run'] = ""
196
197 cxt['steps'].append(step)
198
199 step['link'] = req.childLink("steps/%s" %
200 urllib.quote(s.getName(), safe=''))
201 step['text'] = " ".join(s.getText())
202 step['urls'] = map(lambda x:dict(url=x[1],logname=x[0]), s.getURLs().items())
203
204 step['logs']= []
205 for l in s.getLogs():
206 logname = l.getName()
207 step['logs'].append({ 'link': req.childLink("steps/%s/logs/%s" %
208 (urllib.quote(s.getName(), safe=''),
209 urllib.quote(logname, safe=''))),
210 'name': logname })
211
212 scheduler = b.getProperty("scheduler", None)
213 parameters = {}
214 master = self.getBuildmaster(req)
215 for sch in master.allSchedulers():
216 if isinstance(sch, ForceScheduler) and scheduler == sch.name:
217 for p in sch.all_fields:
218 parameters[p.name] = p
219
220 ps = cxt['properties'] = []
221 for name, value, source in b.getProperties().asList():
222 if not isinstance(value, dict):
223 cxt_value = unicode(value)
224 else:
225 cxt_value = value
226 p = { 'name': name, 'value': cxt_value, 'source': source}
227 if len(cxt_value) > 500:
228 p['short_value'] = cxt_value[:500]
229 if name in parameters:
230 param = parameters[name]
231 if isinstance(param, TextParameter):
232 p['text'] = param.value_to_text(value)
233 p['cols'] = param.cols
234 p['rows'] = param.rows
235 p['label'] = param.label
236 ps.append(p)
237
238
239 cxt['responsible_users'] = list(b.getResponsibleUsers())
240
241 (start, end) = b.getTimes()
242 cxt['start'] = time.ctime(start)
243 if end:
244 cxt['end'] = time.ctime(end)
245 cxt['elapsed'] = util.formatInterval(end - start)
246 else:
247 now = util.now()
248 cxt['elapsed'] = util.formatInterval(now - start)
249
250 exactly = True
251 has_changes = False
252 for ss in sourcestamps:
253 exactly = exactly and (ss.revision is not None)
254 has_changes = has_changes or ss.changes
255 cxt['exactly'] = (exactly) or b.getChanges()
256 cxt['has_changes'] = has_changes
257 cxt['build_url'] = path_to_build(req, b)
258 cxt['authz'] = self.getAuthz(req)
259
260 template = req.site.buildbot_service.templates.get_template("build.html")
261 return template.render(**cxt)
262
263 - def stop(self, req, auth_ok=False):
292
296
308
311 addSlash = True
312
316
317 - def content(self, req, cxt):
318 return "subpages shows data for each build"
319
331