def performAction(self, req): authz = self.getAuthz(req) res = yield authz.actionAllowed('cancelAllPendingBuilds', req) if not res: defer.returnValue(path_to_authzfail(req)) return builders = None if self.selectedOrAll == 'all': builders = self.status.getBuilderNames() elif self.selectedOrAll == 'selected': builders = [b for b in req.args.get("selected", []) if b] c = interfaces.IControl(self.getBuildmaster(req)) for bname in builders: authz = self.getAuthz(req) builder_control = c.getBuilder(bname) brcontrols = yield builder_control.getPendingBuildRequestControls() for build_req in brcontrols: log.msg("Cancelling %s" % build_req) build_req.cancel() # go back to the welcome page defer.returnValue(path_to_root(req))
def performAction(self, req): authz = self.getAuthz(req) d = authz.actionAllowed('forceAllBuilds', req) wfd = defer.waitForDeferred(d) yield wfd res = wfd.getResult() if not res: yield path_to_authfail(req) return builders = None if self.selectedOrAll == 'all': builders = self.status.getBuilderNames() elif self.selectedOrAll == 'selected': builders = [b for b in req.args.get("selected", []) if b] for bname in builders: builder_status = self.status.getBuilder(bname) build = StatusResourceBuilder(builder_status) build.force(req, auth_ok=True) # auth_ok because we already checked # back to the welcome page yield path_to_root(req)
def performAction(self, req): res = yield self.getAuthz(req).actionAllowed('showUsersPage', req) if not res: defer.returnValue(path_to_authzfail(req)) return # show the table defer.returnValue(path_to_root(req) + "users")
def performAction(self, req): authz = self.getAuthz(req) res = yield authz.actionAllowed('stopAllBuilds', req) if not res: defer.returnValue(path_to_authzfail(req)) return builders = None if self.selectedOrAll == 'all': builders = self.status.getBuilderNames() elif self.selectedOrAll == 'selected': builders = [b for b in req.args.get("selected", []) if b] for bname in builders: builder_status = self.status.getBuilder(bname) (state, current_builds) = builder_status.getState() if state != "building": continue for b in current_builds: build_status = builder_status.getBuild(b.number) if not build_status: continue build = StatusResourceBuild(build_status) build.stop(req, auth_ok=True) # go back to the welcome page defer.returnValue(path_to_root(req))
def content(self, request, cxt): status = self.getStatus(request) builders = request.args.get("builder", status.getBuilderNames()) cxt_builders = [] categories = set() for builder_name in builders: if not self.builder_filter_fn(builder_name): continue try: builder_status = status.getBuilder(builder_name) except KeyError: log.msg('status.getBuilder(%r) failed' % builder_name) continue classname = base.ITopBox(builder_status).getBox(request).class_ title = builder_name show_name = 'off' not in request.args.get('titles', ['off']) url = (base.path_to_root(request) + "waterfall?builder=" + urllib.quote(builder_name, safe='() ')) category = builder_status.getCategory() if category: category = category.split('|')[0] categories.add(category) cxt_builders.append({ 'outcome': classname, 'name': title, 'url': url, 'show_name': show_name, 'category': category }) cxt['builders'] = cxt_builders cxt['categories'] = sorted(categories) templates = request.site.buildbot_service.templates template = templates.get_template("horizontal_one_box_per_build.html") data = template.render(cxt) return data
def content(self, request, cxt): status = self.getStatus(request) builders = request.args.get("builder", status.getBuilderNames()) cxt_builders = [] for builder_name in builders: if not self.builder_filter_fn(builder_name): continue try: builder_status = status.getBuilder(builder_name) except KeyError: log.msg('status.getBuilder(%r) failed' % builder_name) continue classname = base.ITopBox(builder_status).getBox(request).class_ title = builder_name show_name = 'off' not in request.args.get('titles', ['off']) url = (base.path_to_root(request) + "waterfall?builder=" + urllib.quote(builder_name, safe='() ')) cxt_builders.append({'outcome': classname, 'name': title, 'url': url, 'show_name': show_name}) cxt['builders'] = cxt_builders templates = request.site.buildbot_service.templates template = templates.get_template("horizontal_one_box_per_build.html") data = template.render(cxt) return data
def content(self, req, cxt): status = self.getStatus(req) builders = req.args.get("builder", status.getBuilderNames()) branches = [b for b in req.args.get("branch", []) if b] # get counts of pending builds for each builder brstatus_ds = [] brcounts = {} def keep_count(statuses, builderName): brcounts[builderName] = len(statuses) for builderName in builders: builder_status = status.getBuilder(builderName) d = builder_status.getPendingBuildRequestStatuses() d.addCallback(keep_count, builderName) brstatus_ds.append(d) yield defer.gatherResults(brstatus_ds) cxt['branches'] = branches bs = cxt['builders'] = [] building = 0 online = 0 base_builders_url = path_to_root(req) + "builders/" for bn in builders: bld = { 'link': base_builders_url + urllib.quote(bn, safe=''), 'name': bn } bs.append(bld) builder = status.getBuilder(bn) builds = list(builder.generateFinishedBuilds(map_branches(branches), num_builds=1)) if builds: b = builds[0] bld['build_url'] = (bld['link'] + "/builds/%d" % b.getNumber()) label = b.getProperty("got_revision") if not label or len(str(label)) > 20: label = "#%d" % b.getNumber() bld['build_label'] = label bld['build_text'] = " ".join(b.getText()) bld['build_css_class'] = build_get_class(b) current_box = ICurrentBox(builder).getBox(status, brcounts) bld['current_box'] = current_box.td() builder_status = builder.getState()[0] if builder_status == "building": building += 1 online += 1 elif builder_status != "offline": online += 1 cxt['authz'] = self.getAuthz(req) cxt['num_building'] = building cxt['num_online'] = online buildForceContext(cxt, req, self.getBuildmaster(req)) template = req.site.buildbot_service.templates.get_template("builders.html") defer.returnValue(template.render(**cxt))
def performAction(self, req): d = self.getAuthz(req).actionAllowed('showUsersPage', req) wfd = defer.waitForDeferred(d) yield wfd res = wfd.getResult() if not res: yield path_to_authzfail(req) return # show the table yield path_to_root(req) + "users/table"
def performAction(self, req): d = self.getAuthz(req).actionAllowed('showUsersPage', req) wfd = defer.waitForDeferred(d) yield wfd res = wfd.getResult() if not res: yield path_to_authzfail(req) return # show the table yield path_to_root(req) + "users"
def content(self, request, cxt): cxt['level'] = self.parent_level cxt['text'] = ToHtml(self.text) cxt['children'] = [n for n in self.parent_children if n != 'help'] cxt['flags'] = ToHtml(FLAGS) cxt['examples'] = ToHtml(EXAMPLES).replace( 'href="/json', 'href="%s' % path_to_root(request) + 'json') template = request.site.buildbot_service.templates.get_template("jsonhelp.html") return template.render(**cxt)
def stopchangeall(self, req): authz = self.getAuthz(req) if not authz.actionAllowed('stopChange', req): return Redirect(path_to_authfail(req)) for bname in self.status.getBuilderNames(): builder_status = self.status.getBuilder(bname) build = StatusResourceBuilder(builder_status) build.stopchange(req, auth_ok=True) return Redirect(path_to_root(req))
def content(self, request, cxt): cxt['level'] = self.parent_level cxt['text'] = ToHtml(self.text) cxt['children'] = [n for n in self.parent_children if n != 'help'] cxt['flags'] = ToHtml(FLAGS) cxt['examples'] = ToHtml(EXAMPLES).replace( 'href="/json', 'href="%s' % path_to_root(request) + 'json') template = request.site.buildbot_service.templates.get_template( "jsonhelp.html") return template.render(**cxt)
def content(self, req, cxt): status = self.getStatus(req) builders = req.args.get("builder", status.getBuilderNames()) branches = [b for b in req.args.get("branch", []) if b] cxt['branches'] = branches bs = cxt['builders'] = [] building = 0 online = 0 base_builders_url = path_to_root(req) + "builders/" for bn in builders: bld = { 'link': base_builders_url + urllib.quote(bn, safe=''), 'name': bn } bs.append(bld) builder = status.getBuilder(bn) builds = list( builder.generateFinishedBuilds(map_branches(branches), num_builds=1)) if builds: b = builds[0] bld['build_url'] = (bld['link'] + "/builds/%d" % b.getNumber()) try: label = b.getProperty("got_revision") except KeyError: label = None if not label or len(str(label)) > 20: label = "#%d" % b.getNumber() bld['build_label'] = label bld['build_text'] = " ".join(b.getText()) bld['build_css_class'] = build_get_class(b) current_box = ICurrentBox(builder).getBox(status) bld['current_box'] = current_box.td() builder_status = builder.getState()[0] if builder_status == "building": building += 1 online += 1 elif builder_status != "offline": online += 1 cxt['authz'] = self.getAuthz(req) cxt['num_building'] = building cxt['num_online'] = online template = req.site.buildbot_service.templates.get_template( "builders.html") return template.render(**cxt)
def forceselected(self, req): authz = self.getAuthz(req) if not authz.actionAllowed('forceAllBuilds', req): return Redirect(path_to_authfail(req)) for bname in [b for b in req.args.get("selected", []) if b]: builder_status = self.status.getBuilder(bname) build = StatusResourceBuilder(builder_status) build.force(req, auth_ok=True) # auth_ok because we already checked # back to the welcome page return Redirect(path_to_root(req))
def __init__(self, msg, req = None, escape = True): if escape: self.msg = cgi.escape(msg) else: self.msg = msg if req: self.suffix = """<p>back to <a href="%s">waterfall</a>.</p>""" % ( path_to_root(req) + "waterfall") else: self.suffix = ""
def forceall(self, req): authz = self.getAuthz(req) if not authz.actionAllowed("forceAllBuilds", req): return Redirect(path_to_authfail(req)) for bname in self.status.getBuilderNames(): builder_status = self.status.getBuilder(bname) build = StatusResourceBuilder(builder_status) build.force(req, auth_ok=True) # auth_ok because we already checked # back to the welcome page return Redirect(path_to_root(req))
def content(self, req, cxt): status = self.getStatus(req) control = self.getControl(req) builders = req.args.get("builder", status.getBuilderNames()) branches = [b for b in req.args.get("branch", []) if b] cxt['branches'] = branches bs = cxt['builders'] = [] building = False online = 0 base_builders_url = path_to_root(req) + "builders/" for bn in builders: bld = { 'link': base_builders_url + urllib.quote(bn, safe=''), 'name': bn } bs.append(bld) builder = status.getBuilder(bn) builds = list(builder.generateFinishedBuilds(map_branches(branches), num_builds=1)) if builds: b = builds[0] bld['build_url'] = (bld['link'] + "/builds/%d" % b.getNumber()) try: label = b.getProperty("got_revision") except KeyError: label = None if not label or len(str(label)) > 20: label = "#%d" % b.getNumber() bld['build_label'] = label bld['build_text'] = " ".join(b.getText()) bld['build_css_class'] = build_get_class(b) current_box = ICurrentBox(builder).getBox(status) bld['current_box'] = current_box.td() builder_status = builder.getState()[0] if builder_status == "building": building = True online += 1 elif builder_status != "offline": online += 1 if control is not None: cxt['use_user_passwd'] = self.isUsingUserPasswd(req) if building: cxt['stop_url'] = "builders/_all/stop" if online: cxt['force_url'] = "builders/_all/force" template = req.site.buildbot_service.templates.get_template("oneboxperbuilder.html") return template.render(**cxt)
def performAction(self, req): authz = self.getAuthz(req) res = authz.authenticated(req) if not res: defer.returnValue(path_to_authzfail(req)) return # save the settings for name, val in req.args.iteritems(): if "_setting" in name: if not isinstance(val, basestring): val = val[0] authz.setUserAttr(req, name.replace("_setting", ""), val) return path_to_root(req) + "users/settings"
def content(self, req, cxt): status = self.getStatus(req) builders = req.args.get("builder", status.getBuilderNames()) branches = [b for b in req.args.get("branch", []) if b] cxt["branches"] = branches bs = cxt["builders"] = [] building = 0 online = 0 base_builders_url = path_to_root(req) + "builders/" for bn in builders: bld = {"link": base_builders_url + urllib.quote(bn, safe=""), "name": bn} bs.append(bld) builder = status.getBuilder(bn) builds = list(builder.generateFinishedBuilds(map_branches(branches), num_builds=1)) if builds: b = builds[0] bld["build_url"] = bld["link"] + "/builds/%d" % b.getNumber() try: label = b.getProperty("got_revision") except KeyError: label = None if not label or len(str(label)) > 20: label = "#%d" % b.getNumber() bld["build_label"] = label bld["build_text"] = " ".join(b.getText()) bld["build_css_class"] = build_get_class(b) current_box = ICurrentBox(builder).getBox(status) bld["current_box"] = current_box.td() builder_status = builder.getState()[0] if builder_status == "building": building += 1 online += 1 elif builder_status != "offline": online += 1 cxt["authz"] = self.getAuthz(req) cxt["num_building"] = online cxt["num_online"] = online template = req.site.buildbot_service.templates.get_template("builders.html") return template.render(**cxt)
def render_GET(self, req): self._setContentType(req) self.req = req if not self.asText: self.template = req.site.buildbot_service.templates.get_template("logs.html") data = self.template.module.page_header( pageTitle = "Log File contents", texturl = req.childLink("text"), path_to_root = path_to_root(req)) data = data.encode('utf-8') req.write(data) self.original.subscribeConsumer(ChunkConsumer(req, self)) return server.NOT_DONE_YET
def performAction(self, req): """Cancel all pending builds that include a given numbered change.""" authz = self.getAuthz(req) res = yield authz.actionAllowed('stopChange', req) if not res: defer.returnValue(path_to_authzfail(req)) return for bname in self.status.getBuilderNames(): builder_status = self.status.getBuilder(bname) res = yield self.stopChangeForBuilder(req, builder_status, auth_ok=True) if not res: defer.returnValue(path_to_authzfail(req)) return defer.returnValue(path_to_root(req))
def performAction(self, req): authz = self.getAuthz(req) res = yield authz.actionAllowed('forceAllBuilds', req) if not res: defer.returnValue(path_to_authzfail(req)) return if self.selectedOrAll == 'all': builderNames = None elif self.selectedOrAll == 'selected': builderNames = [b for b in req.args.get("selected", []) if b] msg = yield self.force(req, builderNames) # back to the welcome page defer.returnValue((path_to_root(req) + "builders", msg))
def performAction(self, req): """Cancel all pending builds that include a given numbered change.""" authz = self.getAuthz(req) if not authz.actionAllowed('stopChange', req): yield path_to_authfail(req) return for bname in self.status.getBuilderNames(): builder_status = self.status.getBuilder(bname) wfd = defer.waitForDeferred( self.stopChangeForBuilder(req, builder_status, auth_ok=True)) yield wfd if not wfd.getResult(): yield path_to_authfail(req) return yield path_to_root(req)
def stopall(self, req): authz = self.getAuthz(req) if not authz.actionAllowed('stopAllBuilds', req): return Redirect(path_to_authfail(req)) for bname in self.status.getBuilderNames(): builder_status = self.status.getBuilder(bname) (state, current_builds) = builder_status.getState() if state != "building": continue for b in current_builds: build_status = builder_status.getBuild(b.number) if not build_status: continue build = StatusResourceBuild(build_status) build.stop(req, auth_ok=True) # go back to the welcome page return Redirect(path_to_root(req))
def stopall(self, req): authz = self.getAuthz(req) if not authz.actionAllowed("stopAllBuilds", req): return Redirect(path_to_authfail(req)) for bname in self.status.getBuilderNames(): builder_status = self.status.getBuilder(bname) (state, current_builds) = builder_status.getState() if state != "building": continue for b in current_builds: build_status = builder_status.getBuild(b.number) if not build_status: continue build = StatusResourceBuild(build_status) build.stop(req, auth_ok=True) # go back to the welcome page return Redirect(path_to_root(req))
def performAction(self, req): authz = self.getAuthz(req) print authz.getUsername(req), authz.authenticated(req) res = yield authz.actionAllowed('forceBuild', req) if not res: defer.returnValue(Redirect(path_to_authzfail(req))) return projects = json.load(open('projects.json')) log.msg('loaded projects.json') log.msg(str(req.args.items())) projectname = req.args.get('projectname', [])[0] projectrepo = req.args.get('projectrepo', [])[0] paths = req.args.get('path', []) boardaddr = req.args.get('boardaddr', [])[0] log.msg(str(req.args.get('arches', []))) arches = req.args.get('arches', ['bluesim']) revisions = req.args.get('revision', []) branches = req.args.get('branch', []) m = re.match('git://github.com/(.*)/(.*).git', projectrepo) if projectname in projects: msg = 'project ' + projectname + ' already exists' elif not m: msg = 'repo "' + projectrepo + ' must be of the form git://github.com/username/project.git' else: p = {"repo": projectrepo} if arches: p['arches'] = arches if paths and paths[0] != '': p['path'] = paths[0] if revisions and revisions[0] != '': p['revision'] = revisions[0] if branches and branches[0] != '': p['branch'] = branches[0] p['owner'] = authz.getUsername(req) projects[projectname] = p json.dump(projects, open('projects.json', 'w'), indent=4) subprocess.call(["/usr/bin/buildbot", "reconfig", "/scratch/buildbot/master"]) msg = 'added project: ' + ' '.join(req.args.get('projectname', '')) + ' url: ' + ' '.join(req.args.get('projectrepo', '')) defer.returnValue((path_to_root(req), msg))
def performAction(self, req): authz = self.getAuthz(req) res = yield authz.actionAllowed('forceAllBuilds', req) if not res: defer.returnValue(path_to_authzfail(req)) return builders = None if self.selectedOrAll == 'all': builders = self.status.getBuilderNames() elif self.selectedOrAll == 'selected': builders = [b for b in req.args.get("selected", []) if b] for bname in builders: builder_status = self.status.getBuilder(bname) ar = ForceBuildActionResource(builder_status) d = ar.performAction(req) d.addErrback(log.err, "(ignored) while trying to force build") # back to the welcome page defer.returnValue(path_to_root(req))
def test_path_to_root_from_one_level(self): self.assertEqual(base.path_to_root(self.fakeRequest(['waterfall'])), './')
def test_path_to_root_from_root(self): self.assertEqual(base.path_to_root(self.fakeRequest([])), './')
def test_path_to_root_from_two_level(self): self.assertEqual(base.path_to_root(self.fakeRequest(['a', 'b'])), '../')
def content_with_db_data(self, changes, brcounts, request, ctx): status = self.getStatus(request) ctx['refresh'] = self.get_reload_time(request) # we start with all Builders available to this Waterfall: this is # limited by the config-file -time categories= argument, and defaults # to all defined Builders. allBuilderNames = status.getBuilderNames(categories=self.categories) builders = [status.getBuilder(name) for name in allBuilderNames] # but if the URL has one or more builder= arguments (or the old show= # argument, which is still accepted for backwards compatibility), we # use that set of builders instead. We still don't show anything # outside the config-file time set limited by categories=. showBuilders = request.args.get("show", []) showBuilders.extend(request.args.get("builder", [])) if showBuilders: builders = [b for b in builders if b.name in showBuilders] # now, if the URL has one or category= arguments, use them as a # filter: only show those builders which belong to one of the given # categories. showCategories = request.args.get("category", []) if showCategories: builders = [b for b in builders if b.category in showCategories] # If the URL has the failures_only=true argument, we remove all the # builders that are not currently red or won't be turning red at the end # of their current run. failuresOnly = request.args.get("failures_only", ["false"])[0] if failuresOnly.lower() == "true": builders = [b for b in builders if not self.isSuccess(b)] (changeNames, builderNames, timestamps, eventGrid, sourceEvents) = \ self.buildGrid(request, builders, changes) # start the table: top-header material locale_enc = locale.getdefaultlocale()[1] if locale_enc is not None: locale_tz = unicode(time.tzname[time.localtime()[-1]], locale_enc) else: locale_tz = unicode(time.tzname[time.localtime()[-1]]) ctx['tz'] = locale_tz ctx['changes_url'] = request.childLink("../changes") bn = ctx['builders'] = [] for name in builderNames: builder = status.getBuilder(name) top_box = ITopBox(builder).getBox(request) current_box = ICurrentBox(builder).getBox(status, brcounts) bn.append({'name': name, 'url': request.childLink("../builders/%s" % urllib.quote(name, safe='')), 'top': top_box.text, 'top_class': top_box.class_, 'status': current_box.text, 'status_class': current_box.class_, }) ctx.update(self.phase2(request, changeNames + builderNames, timestamps, eventGrid, sourceEvents)) def with_args(req, remove_args=[], new_args=[], new_path=None): # sigh, nevow makes this sort of manipulation easier newargs = req.args.copy() for argname in remove_args: newargs[argname] = [] if "branch" in newargs: newargs["branch"] = [b for b in newargs["branch"] if b] for k,v in new_args: if k in newargs: newargs[k].append(v) else: newargs[k] = [v] newquery = "&".join(["%s=%s" % (urllib.quote(k), urllib.quote(v)) for k in newargs for v in newargs[k] ]) if new_path: new_url = new_path elif req.prepath: new_url = req.prepath[-1] else: new_url = '' if newquery: new_url += "?" + newquery return new_url if timestamps: bottom = timestamps[-1] ctx['nextpage'] = with_args(request, ["last_time"], [("last_time", str(int(bottom)))]) helpurl = path_to_root(request) + "waterfall/help" ctx['help_url'] = with_args(request, new_path=helpurl) if self.get_reload_time(request) is not None: ctx['no_reload_page'] = with_args(request, remove_args=["reload"]) template = request.site.buildbot_service.templates.get_template("waterfall.html") data = template.render(**ctx) return data
def content(self, request, ctx): status = self.getStatus(request) ctx['refresh'] = self.get_reload_time(request) # we start with all Builders available to this Waterfall: this is # limited by the config-file -time categories= argument, and defaults # to all defined Builders. allBuilderNames = status.getBuilderNames(categories=self.categories) builders = [status.getBuilder(name) for name in allBuilderNames] # but if the URL has one or more builder= arguments (or the old show= # argument, which is still accepted for backwards compatibility), we # use that set of builders instead. We still don't show anything # outside the config-file time set limited by categories=. showBuilders = request.args.get("show", []) showBuilders.extend(request.args.get("builder", [])) if showBuilders: builders = [b for b in builders if b.name in showBuilders] # now, if the URL has one or category= arguments, use them as a # filter: only show those builders which belong to one of the given # categories. showCategories = request.args.get("category", []) if showCategories: builders = [b for b in builders if b.category in showCategories] # If the URL has the failures_only=true argument, we remove all the # builders that are not currently red or won't be turning red at the end # of their current run. failuresOnly = request.args.get("failures_only", ["false"])[0] if failuresOnly.lower() == "true": builders = [b for b in builders if not self.isSuccess(b)] (changeNames, builderNames, timestamps, eventGrid, sourceEvents) = \ self.buildGrid(request, builders) # start the table: top-header material locale_enc = locale.getdefaultlocale()[1] if locale_enc is not None: locale_tz = unicode(time.tzname[time.localtime()[-1]], locale_enc) else: locale_tz = unicode(time.tzname[time.localtime()[-1]]) ctx['tz'] = locale_tz ctx['changes_url'] = request.childLink("../changes") bn = ctx['builders'] = [] for name in builderNames: builder = status.getBuilder(name) top_box = ITopBox(builder).getBox(request) current_box = ICurrentBox(builder).getBox(status) bn.append({'name': name, 'url': request.childLink("../builders/%s" % urllib.quote(name, safe='')), 'top': top_box.text, 'top_class': top_box.class_, 'status': current_box.text, 'status_class': current_box.class_, }) ctx.update(self.phase2(request, changeNames + builderNames, timestamps, eventGrid, sourceEvents)) def with_args(req, remove_args=[], new_args=[], new_path=None): # sigh, nevow makes this sort of manipulation easier newargs = req.args.copy() for argname in remove_args: newargs[argname] = [] if "branch" in newargs: newargs["branch"] = [b for b in newargs["branch"] if b] for k,v in new_args: if k in newargs: newargs[k].append(v) else: newargs[k] = [v] newquery = "&".join(["%s=%s" % (urllib.quote(k), urllib.quote(v)) for k in newargs for v in newargs[k] ]) if new_path: new_url = new_path elif req.prepath: new_url = req.prepath[-1] else: new_url = '' if newquery: new_url += "?" + newquery return new_url if timestamps: bottom = timestamps[-1] ctx['nextpage'] = with_args(request, ["last_time"], [("last_time", str(int(bottom)))]) helpurl = path_to_root(request) + "waterfall/help" ctx['help_url'] = with_args(request, new_path=helpurl) if self.get_reload_time(request) is not None: ctx['no_reload_page'] = with_args(request, remove_args=["reload"]) template = request.site.buildbot_service.templates.get_template("waterfall.html") data = template.render(**ctx) return data
def content(self, req, cxt): status = self.getStatus(req) builders = req.args.get("builder", status.getBuilderNames()) branches = [b for b in req.args.get("branch", []) if b] # get counts of pending builds for each builder brstatus_ds = [] brcounts = {} def keep_count(statuses, builderName): brcounts[builderName] = len(statuses) for builderName in builders: builder_status = status.getBuilder(builderName) d = builder_status.getPendingBuildRequestStatuses() d.addCallback(keep_count, builderName) brstatus_ds.append(d) wfd = defer.waitForDeferred( defer.gatherResults(brstatus_ds)) yield wfd wfd.getResult() cxt['branches'] = branches bs = cxt['builders'] = [] building = 0 online = 0 base_builders_url = path_to_root(req) + "builders/" for bn in builders: bld = { 'link': base_builders_url + urllib.quote(bn, safe=''), 'name': bn } bs.append(bld) builder = status.getBuilder(bn) builds = list(builder.generateFinishedBuilds(map_branches(branches), num_builds=1)) if builds: b = builds[0] bld['build_url'] = (bld['link'] + "/builds/%d" % b.getNumber()) try: label = b.getProperty("got_revision") except KeyError: label = None if not label or len(str(label)) > 20: label = "#%d" % b.getNumber() bld['build_label'] = label bld['build_text'] = " ".join(b.getText()) bld['build_css_class'] = build_get_class(b) current_box = ICurrentBox(builder).getBox(status, brcounts) bld['current_box'] = current_box.td() builder_status = builder.getState()[0] if builder_status == "building": building += 1 online += 1 elif builder_status != "offline": online += 1 cxt['authz'] = self.getAuthz(req) cxt['num_building'] = building cxt['num_online'] = online template = req.site.buildbot_service.templates.get_template("builders.html") yield template.render(**cxt)
def content(self, req, cxt): status = self.getStatus(req) encoding = getRequestCharset(req) builders = req.args.get("builder", status.getBuilderNames()) branches = [b.decode(encoding) for b in req.args.get("branch", []) if b] # get counts of pending builds for each builder brstatus_ds = [] brcounts = {} def keep_count(statuses, builderName): brcounts[builderName] = len(statuses) for builderName in builders: builder_status = status.getBuilder(builderName) d = builder_status.getPendingBuildRequestStatuses() d.addCallback(keep_count, builderName) brstatus_ds.append(d) yield defer.gatherResults(brstatus_ds) cxt["branches"] = branches bs = cxt["builders"] = [] building = 0 online = 0 base_builders_url = path_to_root(req) + "builders/" for bn in builders: bld = {"link": base_builders_url + urllib.quote(bn, safe=""), "name": bn} bs.append(bld) builder = status.getBuilder(bn) builds = list(builder.generateFinishedBuilds(map_branches(branches), num_builds=1)) if builds: b = builds[0] bld["build_url"] = bld["link"] + "/builds/%d" % b.getNumber() label = None all_got_revisions = b.getAllGotRevisions() # If len = 1 then try if revision can be used as label. if len(all_got_revisions) == 1: label = all_got_revisions[all_got_revisions.keys()[0]] if not label or len(str(label)) > 20: label = "#%d" % b.getNumber() bld["build_label"] = label bld["build_text"] = " ".join(b.getText()) bld["build_css_class"] = build_get_class(b) current_box = ICurrentBox(builder).getBox(status, brcounts) bld["current_box"] = current_box.td() builder_status = builder.getState()[0] if builder_status == "building": building += 1 online += 1 elif builder_status != "offline": online += 1 cxt["authz"] = self.getAuthz(req) cxt["num_building"] = building cxt["num_online"] = online buildForceContext(cxt, req, self.getBuildmaster(req)) template = req.site.buildbot_service.templates.get_template("builders.html") defer.returnValue(template.render(**cxt))
def content(self, req, cxt): status = self.getStatus(req) encoding = getRequestCharset(req) showTags = req.args.get("tag", []) if not showTags: showTags = req.args.get("category", []) if not showTags: showTags = None builders = req.args.get("builder", status.getBuilderNames(tags=showTags)) branches = [ b.decode(encoding) for b in req.args.get("branch", []) if b ] # get counts of pending builds for each builder brstatus_ds = [] brcounts = {} def keep_count(statuses, builderName): brcounts[builderName] = len(statuses) for builderName in builders: builder_status = status.getBuilder(builderName) d = builder_status.getPendingBuildRequestStatuses() d.addCallback(keep_count, builderName) brstatus_ds.append(d) yield defer.gatherResults(brstatus_ds) cxt['branches'] = branches bs = cxt['builders'] = [] building = 0 online = 0 base_builders_url = path_to_root(req) + "builders/" for bn in builders: bld = { 'link': base_builders_url + urllib.quote(bn, safe=''), 'tags': status.getBuilder(bn).tags, 'name': bn } bs.append(bld) builder = status.getBuilder(bn) builds = list( builder.generateFinishedBuilds(map_branches(branches), num_builds=1)) if builds: b = builds[0] bld['build_url'] = (bld['link'] + "/builds/%d" % b.getNumber()) label = None all_got_revisions = b.getAllGotRevisions() # If len = 1 then try if revision can be used as label. if len(all_got_revisions) == 1: label = all_got_revisions[all_got_revisions.keys()[0]] if not label or len(str(label)) > 20: label = "#%d" % b.getNumber() bld['build_label'] = label bld['build_text'] = " ".join(b.getText()) bld['build_css_class'] = build_get_class(b) current_box = ICurrentBox(builder).getBox(status, brcounts) bld['current_box'] = current_box.td() builder_status = builder.getState()[0] if builder_status == "building": building += 1 online += 1 elif builder_status != "offline": online += 1 cxt['authz'] = self.getAuthz(req) cxt['num_building'] = building cxt['num_online'] = online buildForceContext(cxt, req, self.getBuildmaster(req)) template = req.site.buildbot_service.templates.get_template( "builders.html") defer.returnValue(template.render(**cxt))
def render_GET(self, req): self._setContentType(req) self.req = req if self.original.isFinished(): req.setHeader("Cache-Control", "max-age=604800") else: req.setHeader("Cache-Control", "no-cache") if not self.asText: self.template = req.site.buildbot_service.templates.get_template("logs.html") data = self.template.module.page_header( pageTitle="Log File contents", texturl=req.childLink("text"), path_to_root=path_to_root(req) ) data = data.encode("utf-8") req.write(data) self.original.subscribeConsumer(ChunkConsumer(req, self)) return server.NOT_DONE_YET