def body(self, req): status = self.getStatus(req) authz = self.getAuthz(req) builders = req.args.get( "builder", status.getBuilderNames(categories=self.categories)) branches = [b for b in req.args.get("branch", []) if b] if not branches: branches = ["master"] if branches and "master" not in branches: defaultCount = "1" else: defaultCount = "10" num_builds = int(req.args.get("num_builds", [defaultCount])[0]) tag = tags.div() tag(tags.script(src="hlbb.js")) tag(tags.h2(style="float:left; margin-top:0") ("Latest builds: ", ", ".join(branches))) form = tags.form(method="get", action="", style="float:right", onsubmit="return checkBranch(branch.value)") form(tags.input(type="test", name="branch", placeholder=branches[0], size="40")) form(tags.input(type="submit", value="View")) if (yield authz.actionAllowed('forceAllBuilds', req)): # XXX: Unsafe interpolation form(tags.button( type="button", onclick="forceBranch(branch.value || %r, %r)" % (branches[0], self.categories,) )("Force")) tag(form) table = tags.table(style="clear:both") tag(table) for bn in filter(lambda bn: bn not in self.failing_builders, builders): table(self.builder_row(bn, req, branches, num_builds)) table(tags.tr()(tags.td(colspan="100")( tags.h3(style="float:left; margin-top:0") ("Expected failures: ")))) for bn in filter(lambda bn: bn in self.failing_builders, builders): table(self.builder_row(bn, req, branches, num_builds)) defer.returnValue((yield flattenString(req, tag)))
def status(self, request, tag): world = self.factory.world l = [] total = 0 + len(world._cache._dirty) + len(world._pending_chunks) l.append(tags.li("Total chunks: %d" % total)) l.append(tags.li("Clean chunks: %d" % 0)) l.append(tags.li("Dirty chunks: %d" % len(world._cache._dirty))) l.append(tags.li("Chunks being generated: %d" % len(world._pending_chunks))) if world._cache._perm: l.append(tags.li("Permanent cache: enabled, %d chunks" % len(world._cache._perm))) else: l.append(tags.li("Permanent cache: disabled")) status = tags.ul(*l) return tag(tags.h2("Status"), status)
def main(self, request, tag): retval = [] for automaton in factory.automatons: title = tags.h2(automaton.name) stats = [] # Discover tracked information. if hasattr(automaton, "tracked"): t = automaton.tracked if isinstance(t, dict): l = sum(len(i) for i in t.values()) else: l = len(t) stats.append(tags.li("Currently tracking %d blocks" % l)) if hasattr(automaton, "step"): stats.append(tags.li("Currently processing every %f seconds" % automaton.step)) retval.append(tags.div(title, tags.ul(stats))) return tags.div(*retval)
def preview(self, request, tag): docstring = parse_str(self.docstring) stan, errors = epydoc2stan.doc2stan( self.ob, docstring=docstring) if self.isPreview or errors: if errors: #print stan, errors #assert isinstance(stan, tags.pre) [text] = stan.children lines = text.replace('\r\n', '\n').split('\n') line2err = {} for err in errors: if isinstance(err, str): ln = None else: ln = err.linenum() line2err.setdefault(ln, []).append(err) w = len(str(len(lines))) for i, line in enumerate(lines): i += 1 cls = "preview" if i in line2err: cls += " error" tag(tags.pre(class_=cls)("%*s"%(w, i), ' ', line)) for err in line2err.get(i, []): tag(tags.p(class_="errormessage")(err.descr())) i += 1 for err in line2err.get(i, []): tag(tags.p(class_="errormessage")(err.descr())) items = [] for err in line2err.get(None, []): items.append(tags.li(str(err))) if items: tag(tags.ul(items)) else: tag = tag(stan) return tag(tags.h2("Edit")) else: return ()
def bravofactory(self, request, tag, factory): g = (tags.li(username) for username in factory.protocols) users = tags.div(tags.h3("Users"), tags.ul(*g)) world = self.world(request, tags.div, factory.world) return tag(tags.h2("Bravo world %s" % factory.name), users, world)
from klein import Klein, Plating app = Klein() myStyle = Plating( tags=tags.html( tags.head(tags.title(slot("pageTitle"))), tags.body(tags.h1(slot("pageTitle"), Class="titleHeading"), tags.div(slot(Plating.CONTENT))) ), defaults={"pageTitle": "Places & Foods"} ) @myStyle.routed( app.route("/"), tags.div( tags.h2("Sample Places:"), tags.ul([tags.li(tags.a(href=["/places/", place])(place)) for place in ["new york", "san francisco", "shanghai"]]), tags.h2("Sample Foods:"), tags.ul([tags.li(tags.a(href=["/foods/", food])(food)) for food in ["hamburgers", "cheeseburgers", "hot dogs"]]), )) def root(request): return {} @myStyle.routed(app.route("/foods/<food>"), tags.table(border="2", style="color: blue")( tags.tr(tags.td("Name:"), tags.td(slot("name"))), tags.tr(tags.td("Deliciousness:"), tags.td(slot("rating"), " stars")), tags.tr(tags.td("Carbs:"),
def user(self, request, tag): users = (tags.li(username) for username in self.factory.protocols) return tag(tags.h2("Users"), tags.ul(*users))
def world(self, request, tag): worlds = [] for name in self.worlds.keys(): worlds.append(tags.li(tags.a(name.title(), href=name))) return tag(tags.h2("Worlds"), tags.ul(*worlds))
def service(self, request, tag): services = [] for name, factory in self.services.iteritems(): services.append(tags.li("%s (%s)" % (name, factory.__class__))) return tag(tags.h2("Services"), tags.ul(*services))
def plugin(self, request, tag): plugins = [] for name in self.plugins.keys(): plugins.append(tags.li(tags.a(name.title(), href='%s/%s' % (self.factory.name, name)))) return tag(tags.h2("Plugins"), tags.ul(*plugins))
def body(self, req): status = self.getStatus(req) authz = self.getAuthz(req) builders = req.args.get("builder", status.getBuilderNames(categories=self.categories)) branches = [b for b in req.args.get("branch", []) if b] if not branches: branches = ["trunk"] if branches and "trunk" not in branches: defaultCount = "1" else: defaultCount = "10" num_builds = int(req.args.get("num_builds", [defaultCount])[0]) tag = tags.div() tag(tags.script(src="txbuildbot.js")) tag(tags.h2(style="float:left; margin-top:0")("Latest builds: ", ", ".join(branches))) form = tags.form(method="get", action="", style="float:right", onsubmit="return checkBranch(branch.value)") form(tags.input(type="test", name="branch", placeholder=branches[0], size="40")) form(tags.input(type="submit", value="View")) if (yield authz.actionAllowed('forceAllBuilds', req)): # XXX: Unsafe interpolation form(tags.button(type="button", onclick="forceBranch(branch.value || %r, %r)" % (branches[0], self.categories,) )("Force")) tag(form) table = tags.table(style="clear:both") tag(table) for bn in builders: builder = status.getBuilder(bn) state = builder.getState()[0] if state == 'building': state = 'idle' row = tags.tr() table(row) builderLink = path_to_builder(req, builder) row(tags.td(class_="box %s" % (state,))(tags.a(href=builderLink)(bn))) builds = sorted([ build for build in builder.getCurrentBuilds() if build.getSourceStamps()[0].branch in map_branches(branches) ], key=lambda build: build.getNumber(), reverse=True) builds.extend(builder.generateFinishedBuilds(map_branches(branches), num_builds=num_builds)) if builds: for b in builds: url = path_to_build(req, b) try: label = b.getProperty("got_revision") except KeyError: label = None # Label should never be "None", but sometimes # buildbot has disgusting bugs. if not label or label == "None" or len(str(label)) > 20: label = "#%d" % b.getNumber() if b.isFinished(): text = b.getText() else: when = b.getETA() if when: text = [ "%s" % (formatInterval(when),), "%s" % (time.strftime("%H:%M:%S", time.localtime(time.time() + when)),) ] else: text = [] row(tags.td( align="center", bgcolor=_backgroundColors[b.getResults()], class_=("LastBuild box ", build_get_class(b)))([ (element, tags.br) for element in [tags.a(href=url)(label)] + text]) ) else: row(tags.td(class_="LastBuild box")("no build")) defer.returnValue((yield flattenString(req, tag)))