def head(self, request: IRequest, tag: Tag = tags.head) -> KleinRenderable: """ <head> element. """ urls = self.config.urls children = tag.children tag.children = [] return tag( tags.meta(charset="utf-8"), tags.meta(name="viewport", content="width=device-width, initial-scale=1"), tags.link( type="image/png", rel="icon", href=urls.logo.asText(), ), tags.link( type="text/css", rel="stylesheet", media="screen", href=urls.bootstrapCSS.asText(), ), tags.link( type="text/css", rel="stylesheet", media="screen", href=urls.styleSheet.asText(), ), tags.script(src=urls.jqueryJS.asText()), tags.script(src=urls.bootstrapJS.asText()), self.title(request), children, )
def head(self, request, tag=None): if tag is None: children = () tag = tags.head else: children = tag.children tag.children = [] return tag( tags.meta(charset="utf-8"), tags.meta( name="viewport", content="width=device-width, initial-scale=1" ), tags.link( type="image/png", rel="icon", href=URLs.logo.asText(), ), tags.link( type="text/css", rel="stylesheet", media="screen", href=URLs.bootstrapCSS.asText(), ), tags.link( type="text/css", rel="stylesheet", media="screen", href=URLs.styleSheet.asText(), ), tags.script(src=URLs.jqueryJS.asText()), tags.script(src=URLs.bootstrapJS.asText()), self.title(request, tags.title), children, )
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 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 head(self, request: IRequest, tag: Tag) -> KleinRenderable: """ `<head>` element. """ urls = self.config.urls children = tag.children tag.children = [] imports = (tags.script(src=url.asText()) for url in self.urlsFromImportSpec( tag.attributes.get("imports", ""))) if "imports" in tag.attributes: del tag.attributes["imports"] return tag( # Resource metadata tags.meta(charset="utf-8"), tags.meta(name="viewport", content="width=device-width, initial-scale=1"), tags.link( type="image/png", rel="icon", href=urls.logo.asText(), ), tags.link( type="text/css", rel="stylesheet", media="screen", href=urls.bootstrapCSS.asText(), ), tags.link( type="text/css", rel="stylesheet", media="screen", href=urls.styleSheet.asText(), ), self.title(request, tags.title.clone()), # JavaScript resource imports imports, # Child elements children, )
def head(self, request: IRequest, tag: Tag) -> KleinRenderable: """ `<head>` element. """ urls = self.config.urls children = tag.children tag.children = [] imports = ( tags.script(src=url.asText()) for url in self.urlsFromImportSpec(tag.attributes.get("imports", "")) ) if "imports" in tag.attributes: del tag.attributes["imports"] return tag( # Resource metadata tags.meta(charset="utf-8"), tags.meta( name="viewport", content="width=device-width, initial-scale=1" ), tags.link( type="image/png", rel="icon", href=urls.logo.asText(), ), tags.link( type="text/css", rel="stylesheet", media="screen", href=urls.bootstrapCSS.asText(), ), tags.link( type="text/css", rel="stylesheet", media="screen", href=urls.styleSheet.asText(), ), self.title(request, tags.title.clone()), # JavaScript resource imports imports, # Child elements children, )
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.getSourceStamp().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)))
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)))
def render_GET(self, request): root = tags.head( tags.script(src='https://login.persona.org/provisioning_api.js'), certEmailScriptTag(self.verifier, request), tags.script(JS['provisioning.js'])) return renderElement(request, root)
def certEmailScriptTag(verifier, request): try: email = verifier.furnishRequestEmail(request) except UnverifiedPeer: email = None return tags.script('var cert_email = %s;' % (json.dumps(email),))
def make_html(components, instances): table = tags.table(class_='main') heading_row = tags.tr() for heading in 'component', 'tip revno', 'unreleased revisions', 'latest release': heading_row(tags.th(heading)) for instance_name in sorted(instances): heading_row(tags.th(instance_name, class_="instance-name")) table(tags.thead(heading_row)) tbody = tags.tbody() for name, component in sorted(components.items()): row = tags.tr(class_="component") revs_between_ids = {} extra_rows = [] def td(*args, **kwargs): row(tags.td(*args, **kwargs)) td(name) td(str(component.tip_revno), class_='version') unreleased_count = len(component.unreleased_revisions) if unreleased_count: id_ = get_id() td( tags.a(str(unreleased_count), href='#', class_='highlight'), class_='version clickable', id=id_) sub_name = 'revs between %s (r%s) and tip (r%s)' % ( component.last_release, component.released_revno, component.tip_revno) extra_rows.append( tags.tr( tags.td( format_revlist(component.unreleased_revisions, name=sub_name), colspan=str(4 + len(instances))), class_='hidden', id="show-" + id_)) elif not component.last_release: td(u'\N{EM DASH}', class_='version') else: td(str(unreleased_count), class_='version') if component.last_release: td(component.last_release, class_='version') else: td(u'???', class_='version') for instance_name, instance in sorted(instances.items()): ver, location = instance.get(name, (None, None)) if ver is None: td(u'\N{EM DASH}', class_='version') elif ver == component.last_release: td(ver, class_='version') elif ver in component.release2revno: revno_low = component.release2revno[ver] sub_name = 'revs between %s (r%s) and %s (r%s)' % ( ver, revno_low, component.last_release, component.released_revno) revlist = [] for rev, revno in component.mainline_revs: if revno_low < revno < component.released_revno: revlist.append((rev, revno)) if revlist: id_ = get_id() revs_between_ids[revno_low] = id_ extra_rows.append( tags.tr( tags.td( format_revlist(revlist, name=sub_name), colspan=str(4 + len(instances))), class_='hidden branch-diff', id="show-" + id_)) td( tags.a(ver, href='#', class_='highlight'), class_='version clickable', id=id_) else: td(tags.span(ver, class_='highlight'), class_='version') elif location: try: branch = bzrlib.branch.Branch.open(location) except bzrlib.errors.NoSuchBranch: td(tags.span(ver, class_='highlight'), class_='version') else: branch.lock_read() try: # This utterly half-assed version of bzr missing # doesn't take merges into account! revno, revid = branch.last_revision_info() ver = ver.split('dev')[0] + 'dev' + str(revno) mainline_revids = dict( (rev.revision_id, revno) for rev, revno in component.mainline_revs) in_branch_revs = [] while revid not in mainline_revids: rev = branch.repository.get_revision(revid) if rev.message != 'post release bump': in_branch_revs.append((rev, revno)) revno -= 1 if not rev.parent_ids: break revid = rev.parent_ids[0] tables = [] if in_branch_revs: tables.append( format_revlist( in_branch_revs, 'in branch (with nick %s) but not tip' % branch.nick)) in_trunk_revs = [] lca_revno = revno for rev, revno in component.mainline_revs: if revno > lca_revno: in_trunk_revs.append((rev, revno)) if in_trunk_revs: tables.append( format_revlist( in_trunk_revs, 'in tip but not branch')) if tables: id_ = get_id() td( tags.a(ver, href='#', class_='highlight'), class_='version clickable', id=id_) extra_rows.append( tags.tr( tags.td( tables, colspan=str(4 + len(instances))), class_='hidden branch-diff', id="show-" + id_)) else: if branch.last_revision() == component.tip_revno: td(ver, class_='highlight version') else: td(ver, class_='version') finally: branch.unlock() else: td(tags.span(ver, class_='highlight'), class_='version') tbody(row, *extra_rows) table(tbody) html = tags.html( tags.head( tags.title("Deployment report"), tags.script( src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', type='text/javascript'), tags.script( src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js', type='text/javascript'), tags.script(CDATA(js), type='text/javascript'), tags.style(CDATA(css), type="text/css"), ), tags.body( tags.h1("Deployment report"), table, ), ) html(xmlns="http://www.w3.org/1999/xhtml") return DOCTYPE + flatten(html)
def make_html(components, instances): table = tags.table(class_='main') heading_row = tags.tr() for heading in 'component', 'tip revno', 'unreleased revisions', 'latest release': heading_row(tags.th(heading)) for instance_name in sorted(instances): heading_row(tags.th(instance_name, class_="instance-name")) table(tags.thead(heading_row)) tbody = tags.tbody() for name, component in sorted(components.items()): row = tags.tr(class_="component") revs_between_ids = {} extra_rows = [] def td(*args, **kwargs): row(tags.td(*args, **kwargs)) td(name) td(str(component.tip_revno), class_='version') unreleased_count = len(component.unreleased_revisions) if unreleased_count: id_ = get_id() td(tags.a(str(unreleased_count), href='#', class_='highlight'), class_='version clickable', id=id_) sub_name = 'revs between %s (r%s) and tip (r%s)' % ( component.last_release, component.released_revno, component.tip_revno) extra_rows.append( tags.tr(tags.td(format_revlist(component.unreleased_revisions, name=sub_name), colspan=str(4 + len(instances))), class_='hidden', id="show-" + id_)) elif not component.last_release: td(u'\N{EM DASH}', class_='version') else: td(str(unreleased_count), class_='version') if component.last_release: td(component.last_release, class_='version') else: td(u'???', class_='version') for instance_name, instance in sorted(instances.items()): ver, location = instance.get(name, (None, None)) if ver is None: td(u'\N{EM DASH}', class_='version') elif ver == component.last_release: td(ver, class_='version') elif ver in component.release2revno: revno_low = component.release2revno[ver] sub_name = 'revs between %s (r%s) and %s (r%s)' % ( ver, revno_low, component.last_release, component.released_revno) revlist = [] for rev, revno in component.mainline_revs: if revno_low < revno < component.released_revno: revlist.append((rev, revno)) if revlist: id_ = get_id() revs_between_ids[revno_low] = id_ extra_rows.append( tags.tr(tags.td(format_revlist(revlist, name=sub_name), colspan=str(4 + len(instances))), class_='hidden branch-diff', id="show-" + id_)) td(tags.a(ver, href='#', class_='highlight'), class_='version clickable', id=id_) else: td(tags.span(ver, class_='highlight'), class_='version') elif location: try: branch = bzrlib.branch.Branch.open(location) except bzrlib.errors.NoSuchBranch: td(tags.span(ver, class_='highlight'), class_='version') else: branch.lock_read() try: # This utterly half-assed version of bzr missing # doesn't take merges into account! revno, revid = branch.last_revision_info() ver = ver.split('dev')[0] + 'dev' + str(revno) mainline_revids = dict( (rev.revision_id, revno) for rev, revno in component.mainline_revs) in_branch_revs = [] while revid not in mainline_revids: rev = branch.repository.get_revision(revid) if rev.message != 'post release bump': in_branch_revs.append((rev, revno)) revno -= 1 if not rev.parent_ids: break revid = rev.parent_ids[0] tables = [] if in_branch_revs: tables.append( format_revlist( in_branch_revs, 'in branch (with nick %s) but not tip' % branch.nick)) in_trunk_revs = [] lca_revno = revno for rev, revno in component.mainline_revs: if revno > lca_revno: in_trunk_revs.append((rev, revno)) if in_trunk_revs: tables.append( format_revlist(in_trunk_revs, 'in tip but not branch')) if tables: id_ = get_id() td(tags.a(ver, href='#', class_='highlight'), class_='version clickable', id=id_) extra_rows.append( tags.tr(tags.td(tables, colspan=str(4 + len(instances))), class_='hidden branch-diff', id="show-" + id_)) else: if branch.last_revision() == component.tip_revno: td(ver, class_='highlight version') else: td(ver, class_='version') finally: branch.unlock() else: td(tags.span(ver, class_='highlight'), class_='version') tbody(row, *extra_rows) table(tbody) html = tags.html( tags.head( tags.title("Deployment report"), tags.script( src= 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', type='text/javascript'), tags.script( src= 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js', type='text/javascript'), tags.script(CDATA(js), type='text/javascript'), tags.style(CDATA(css), type="text/css"), ), tags.body( tags.h1("Deployment report"), table, ), ) html(xmlns="http://www.w3.org/1999/xhtml") return DOCTYPE + flatten(html)