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

Source Code for Module buildbot.status.web.step

  1   
  2  from twisted.web import html 
  3   
  4  import urllib 
  5  from buildbot.status.web.base import HtmlResource, path_to_builder, \ 
  6       path_to_build 
  7  from buildbot.status.web.logs import LogsResource 
  8  from buildbot import util 
  9  from time import ctime 
 10   
 11  # /builders/$builder/builds/$buildnum/steps/$stepname 
12 -class StatusResourceBuildStep(HtmlResource):
13 title = "Build Step" 14 addSlash = True 15
16 - def __init__(self, build_status, step_status):
20
21 - def body(self, req):
22 s = self.step_status 23 b = s.getBuild() 24 builder_name = b.getBuilder().getName() 25 build_num = b.getNumber() 26 data = "" 27 data += ('<h1>BuildStep <a href="%s">%s</a>:' % 28 (path_to_builder(req, b.getBuilder()), builder_name)) 29 data += '<a href="%s">#%d</a>' % (path_to_build(req, b), build_num) 30 data += ":%s</h1>\n" % s.getName() 31 32 if s.isFinished(): 33 data += ("<h2>Finished</h2>\n" 34 "<p>%s</p>\n" % html.escape("%s" % s.getText())) 35 else: 36 data += ("<h2>Not Finished</h2>\n" 37 "<p>ETA %s seconds</p>\n" % s.getETA()) 38 39 exp = s.getExpectations() 40 if exp: 41 data += ("<h2>Expectations</h2>\n" 42 "<ul>\n") 43 for e in exp: 44 data += "<li>%s: current=%s, target=%s</li>\n" % \ 45 (html.escape(e[0]), e[1], e[2]) 46 data += "</ul>\n" 47 48 (start, end) = s.getTimes() 49 data += "<h2>Timing</h2>\n" 50 data += "<table>\n" 51 data += "<tr><td>Start</td><td>%s</td></tr>\n" % ctime(start) 52 if end: 53 data += "<tr><td>End</td><td>%s</td></tr>\n" % ctime(end) 54 data += "<tr><td>Elapsed</td><td>%s</td></tr>\n" % util.formatInterval(end - start) 55 else: 56 now = util.now() 57 data += "<tr><td>Elapsed</td><td>%s</td></tr>\n" % util.formatInterval(now - start) 58 data += "</table>\n" 59 60 logs = s.getLogs() 61 if logs: 62 data += ("<h2>Logs</h2>\n" 63 "<ul>\n") 64 for logfile in logs: 65 if logfile.hasContents(): 66 # FIXME: If the step name has a / in it, this is broken 67 # either way. If we quote it but say '/'s are safe, 68 # it chops up the step name. If we quote it and '/'s 69 # are not safe, it escapes the / that separates the 70 # step name from the log number. 71 logname = logfile.getName() 72 logurl = req.childLink("logs/%s" % urllib.quote(logname)) 73 data += ('<li><a href="%s">%s</a></li>\n' % 74 (logurl, html.escape(logname))) 75 else: 76 data += '<li>%s</li>\n' % html.escape(logname) 77 data += "</ul>\n" 78 79 return data
80
81 - def getChild(self, path, req):
82 if path == "logs": 83 return LogsResource(self.step_status) 84 return HtmlResource.getChild(self, path, req)
85 86 87 88 # /builders/$builder/builds/$buildnum/steps
89 -class StepsResource(HtmlResource):
90 addSlash = True 91
92 - def __init__(self, build_status):
95
96 - def getChild(self, path, req):
97 for s in self.build_status.getSteps(): 98 if s.getName() == path: 99 return StatusResourceBuildStep(self.build_status, s) 100 return HtmlResource.getChild(self, path, req)
101