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 got = 0 51 building = 0 52 online = 0 53 54 builders = cxt['builds'] = [] 55 for build in g: 56 got += 1 57 builders.append(self.get_line_values(req, build)) 58 builder_status = build.getBuilder().getState()[0] 59 if builder_status == "building": 60 building += 1 61 online += 1 62 elif builder_status != "offline": 63 online += 1 64 65 cxt['authz'] = self.getAuthz(req) 66 cxt['num_online'] = online 67 cxt['num_building'] = building 68 69 template = req.site.buildbot_service.templates.get_template('onelineperbuild.html') 70 return template.render(**cxt)
71 72 73 74 # /one_line_per_build/$BUILDERNAME 75 # accepts branch=, numbuilds= 76
77 -class OneLinePerBuildOneBuilder(HtmlResource, BuildLineMixin):
78 - def __init__(self, builder, numbuilds=20):
79 HtmlResource.__init__(self) 80 self.builder = builder 81 self.builder_name = builder.getName() 82 self.numbuilds = numbuilds 83 self.title = "Recent Builds of %s" % self.builder_name
84
85 - def content(self, req, cxt):
86 numbuilds = int(req.args.get("numbuilds", [self.numbuilds])[0]) 87 branches = [b for b in req.args.get("branch", []) if b] 88 89 # walk backwards through all builds of a single builder 90 g = self.builder.generateFinishedBuilds(map_branches(branches), 91 numbuilds) 92 93 cxt['builds'] = map(lambda b: self.get_line_values(req, b), g) 94 cxt.update(dict(num_builds=numbuilds, 95 builder_name=self.builder_name, 96 branches=branches)) 97 98 template = req.site.buildbot_service.templates.get_template('onelineperbuildonebuilder.html') 99 return template.render(**cxt)
100