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 pageTitle = "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 stepStatistics = s.getStatistics() 50 statistics = cxt['statistics'] = [] 51 for stat in stepStatistics: 52 statistics.append({'name': stat, 'value': stepStatistics[stat]}) 53 54 start, end = s.getTimes() 55 56 if start: 57 cxt['start'] = ctime(start) 58 if end: 59 cxt['end'] = ctime(end) 60 cxt['elapsed'] = util.formatInterval(end - start) 61 else: 62 cxt['end'] = "Not Finished" 63 cxt['elapsed'] = util.formatInterval(util.now() - start) 64 65 cxt.update(dict(builder_link = path_to_builder(req, b.getBuilder()), 66 build_link = path_to_build(req, b), 67 b = b, 68 s = s, 69 result_css = css_classes[s.getResults()[0]])) 70 71 template = req.site.buildbot_service.templates.get_template("buildstep.html"); 72 return template.render(**cxt)
73
74 - def getChild(self, path, req):
75 if path == "logs": 76 return LogsResource(self.step_status) 77 return HtmlResource.getChild(self, path, req)
78 79 80 81 # /builders/$builder/builds/$buildnum/steps
82 -class StepsResource(HtmlResource):
83 addSlash = True 84
85 - def __init__(self, build_status):
88
89 - def content(self, req, ctx):
90 return "subpages show data for each step"
91
92 - def getChild(self, path, req):
93 for s in self.build_status.getSteps(): 94 if s.getName() == path: 95 return StatusResourceBuildStep(self.build_status, s) 96 return HtmlResource.getChild(self, path, req)
97