def getAllBuildsForRevision(self, status, request, codebase, lastRevision, numBuilds, tags, builders, debugInfo): """Returns a dictionary of builds we need to inspect to be able to display the console page. The key is the builder name, and the value is an array of build we care about. We also returns a dictionary of builders we care about. The key is it's category. codebase is the codebase to get revisions from lastRevision is the last revision we want to display in the page. tags is a list of tags to display. It is coming from the HTTP GET parameters. builders is a list of builders to display. It is coming from the HTTP GET parameters. """ allBuilds = dict() # List of all builders in the dictionary. builderList = dict() debugInfo["builds_scanned"] = 0 # Get all the builders. builderNames = status.getBuilderNames()[:] for builderName in builderNames: builder = status.getBuilder(builderName) # Make sure we are interested in this builder. if tags and not builder.matchesAnyTag(tags): continue if builders and builderName not in builders: continue # We want to display this builder. builder_tags = builder.getTags() or ["default"] for tag in builder_tags: # Append this builder to the dictionary of builders. builderList.setdefault(tag, []).append(builderName) # Set the list of builds for this builder. allBuilds[builderName] = self.getBuildsForRevision(request, builder, builderName, codebase, lastRevision, numBuilds, debugInfo) return (builderList, allBuilds)
def getAllBuildsForRevision(self, status, request, codebase, lastRevision, numBuilds, tags, builders, debugInfo): """Returns a dictionary of builds we need to inspect to be able to display the console page. The key is the builder name, and the value is an array of build we care about. We also returns a dictionary of builders we care about. The key is it's category. codebase is the codebase to get revisions from lastRevision is the last revision we want to display in the page. tags is a list of tags to display. It is coming from the HTTP GET parameters. builders is a list of builders to display. It is coming from the HTTP GET parameters. """ allBuilds = dict() # List of all builders in the dictionary. builderList = dict() debugInfo["builds_scanned"] = 0 # Get all the builders. builderNames = status.getBuilderNames()[:] for builderName in builderNames: builder = status.getBuilder(builderName) # Make sure we are interested in this builder. if tags and not builder.matchesAnyTag(tags): continue if builders and builderName not in builders: continue # We want to display this builder. builder_tags = builder.getTags() or ["default"] for tag in builder_tags: # Append this builder to the dictionary of builders. builderList.setdefault(tag, []).append(builderName) # Set the list of builds for this builder. allBuilds[builderName] = self.getBuildsForRevision( request, builder, builderName, codebase, lastRevision, numBuilds, debugInfo) return (builderList, allBuilds)
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 tags= argument, and defaults # to all defined Builders. allBuilderNames = status.getBuilderNames(tags=self.tags) 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 tags=. 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 # tags. showTags = request.args.get("tag", []) if not showTags: showTags = request.args.get("category", []) if showTags: builders = [b for b in builders if b.matchesAnyTag(showTags)] # 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"]) # get alphabetically sorted list of all tags tags = set() builderNames = status.getBuilderNames() for builderName in builderNames: builder = status.getBuilder(builderName) tags.update(builder.getTags() or []) tags = util.naturalSort(list(tags)) ctx['tags'] = tags template = request.site.buildbot_service.templates.get_template( "waterfall.html") data = template.render(**ctx) return data
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 tags= argument, and defaults # to all defined Builders. allBuilderNames = status.getBuilderNames(tags=self.tags) 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 tags=. 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 # tags. showTags = request.args.get("tag", []) if not showTags: showTags = request.args.get("category", []) if showTags: builders = [b for b in builders if b.matchesAnyTag(showTags)] # 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"]) # get alphabetically sorted list of all tags tags = set() builderNames = status.getBuilderNames() for builderName in builderNames: builder = status.getBuilder(builderName) tags.update(builder.getTags() or []) tags = sorted(tags) ctx['tags'] = tags template = request.site.buildbot_service.templates.get_template("waterfall.html") data = template.render(**ctx) return data