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

Source Code for Module buildbot.status.web.olpb

  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  from buildbot.status.web.base import HtmlResource, BuildLineMixin, map_branches 
 18   
 19  # /one_line_per_build 
 20  #  accepts builder=, branch=, numbuilds=, reload= 
21 -class OneLinePerBuild(HtmlResource, BuildLineMixin):
22 """This shows one line per build, combining all builders together. Useful 23 query arguments: 24 25 numbuilds=: how many lines to display 26 builder=: show only builds for this builder. Multiple builder= arguments 27 can be used to see builds from any builder in the set. 28 reload=: reload the page after this many seconds 29 """ 30 31 pageTitle = "Recent Builds" 32
33 - def __init__(self, numbuilds=20):
34 HtmlResource.__init__(self) 35 self.numbuilds = numbuilds
36
37 - def getChild(self, path, req):
38 status = self.getStatus(req) 39 builder = status.getBuilder(path) 40 return OneLinePerBuildOneBuilder(builder, numbuilds=self.numbuilds)
41
42 - def get_reload_time(self, request):
43 if "reload" in request.args: 44 try: 45 reload_time = int(request.args["reload"][0]) 46 return max(reload_time, 15) 47 except ValueError: 48 pass 49 return None
50
51 - def content(self, req, cxt):
52 status = self.getStatus(req) 53 numbuilds = int(req.args.get("numbuilds", [self.numbuilds])[0]) 54 builders = req.args.get("builder", []) 55 branches = [b for b in req.args.get("branch", []) if b] 56 57 g = status.generateFinishedBuilds(builders, map_branches(branches), 58 numbuilds, max_search=numbuilds) 59 60 cxt['refresh'] = self.get_reload_time(req) 61 cxt['num_builds'] = numbuilds 62 cxt['branches'] = branches 63 cxt['builders'] = builders 64 65 builds = cxt['builds'] = [] 66 for build in g: 67 builds.append(self.get_line_values(req, build)) 68 69 cxt['authz'] = self.getAuthz(req) 70 71 # get information on the builders - mostly just a count 72 building = 0 73 online = 0 74 for bn in builders: 75 builder = status.getBuilder(bn) 76 builder_status = builder.getState()[0] 77 if builder_status == "building": 78 building += 1 79 online += 1 80 elif builder_status != "offline": 81 online += 1 82 83 cxt['num_online'] = online 84 cxt['num_building'] = building 85 86 template = req.site.buildbot_service.templates.get_template('onelineperbuild.html') 87 return template.render(**cxt)
88 89 90 91 # /one_line_per_build/$BUILDERNAME 92 # accepts branch=, numbuilds= 93
94 -class OneLinePerBuildOneBuilder(HtmlResource, BuildLineMixin):
95 - def __init__(self, builder, numbuilds=20):
96 HtmlResource.__init__(self) 97 self.builder = builder 98 self.builder_name = builder.getName() 99 self.numbuilds = numbuilds 100 self.pageTitle = "Recent Builds of %s" % self.builder_name
101
102 - def content(self, req, cxt):
103 numbuilds = int(req.args.get("numbuilds", [self.numbuilds])[0]) 104 branches = [b for b in req.args.get("branch", []) if b] 105 106 # walk backwards through all builds of a single builder 107 g = self.builder.generateFinishedBuilds(map_branches(branches), 108 numbuilds) 109 110 cxt['builds'] = map(lambda b: self.get_line_values(req, b), g) 111 cxt.update(dict(num_builds=numbuilds, 112 builder_name=self.builder_name, 113 branches=branches)) 114 115 template = req.site.buildbot_service.templates.get_template('onelineperbuildonebuilder.html') 116 return template.render(**cxt)
117