Package buildbot :: Package status :: Package web :: Module step
[frames] | no frames]

Source Code for Module buildbot.status.web.step

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16   
17  import urllib 
18  from buildbot.status.web.base import HtmlResource, path_to_builder, \ 
19       path_to_build, css_classes 
20  from buildbot.status.web.logs import LogsResource 
21  from buildbot import util 
22  from time import ctime 
23   
24  # /builders/$builder/builds/$buildnum/steps/$stepname 
25 -class StatusResourceBuildStep(HtmlResource):
26 title = "Build Step" 27 addSlash = True 28
29 - def __init__(self, build_status, step_status):
33
34 - def content(self, req, cxt):
35 s = self.step_status 36 b = s.getBuild() 37 38 logs = cxt['logs'] = [] 39 for l in s.getLogs(): 40 # FIXME: If the step name has a / in it, this is broken 41 # either way. If we quote it but say '/'s are safe, 42 # it chops up the step name. If we quote it and '/'s 43 # are not safe, it escapes the / that separates the 44 # step name from the log number. 45 logs.append({'has_contents': l.hasContents(), 46 'name': l.getName(), 47 'link': req.childLink("logs/%s" % urllib.quote(l.getName())) }) 48 49 start, end = s.getTimes() 50 51 if start: 52 cxt['start'] = ctime(start) 53 if end: 54 cxt['end'] = ctime(end) 55 cxt['elapsed'] = util.formatInterval(end - start) 56 else: 57 cxt['end'] = "Not Finished" 58 cxt['elapsed'] = util.formatInterval(util.now() - start) 59 60 cxt.update(dict(builder_link = path_to_builder(req, b.getBuilder()), 61 build_link = path_to_build(req, b), 62 b = b, 63 s = s, 64 result_css = css_classes[b.getResults()])) 65 66 template = req.site.buildbot_service.templates.get_template("buildstep.html"); 67 return template.render(**cxt)
68
69 - def getChild(self, path, req):
70 if path == "logs": 71 return LogsResource(self.step_status) 72 return HtmlResource.getChild(self, path, req)
73 74 75 76 # /builders/$builder/builds/$buildnum/steps
77 -class StepsResource(HtmlResource):
78 addSlash = True 79
80 - def __init__(self, build_status):
83
84 - def content(self, req, ctx):
85 return "subpages show data for each step"
86
87 - def getChild(self, path, req):
88 for s in self.build_status.getSteps(): 89 if s.getName() == path: 90 return StatusResourceBuildStep(self.build_status, s) 91 return HtmlResource.getChild(self, path, req)
92