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

Source Code for Module buildbot.status.web.olpb

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