return "<a href='%s'>%s</a>" % (build_uri(myself, build), html_build_status(build.status()))
+def tree_uri(myself, tree):
+ return "%s/tree/%s" % (myself, tree.name)
+
+
+def tree_link(myself, tree):
+ """return a link to a particular tree"""
+ return "<a href='%s' title='View recent builds for %s'>%s:%s</a>" % (tree_uri(myself, tree), tree.name, tree.name, tree.branch)
+
+
def host_uri(myself, host):
- return "%s?function=View+Host;host=%s" % (myself, host)
+ return "%s/host/%s" % (myself, host)
def host_link(myself, host):
return "<a href='%s'>%s</a>" % (host_uri(myself, host), host)
return "failed"
elif subunit_result == "xfail":
return "xfailed"
+ elif subunit_result == "uxsuccess":
+ return "uxpassed"
else:
return "unknown"
log = re.sub("""
^test: ([\w\-=,_:\ /.&; \(\)]+).*?
(.*?)
- (success|xfail|failure|skip): [\w\-=,_:\ /.&; \(\)]+( \[.*?\])?.*?
+ (success|xfail|failure|skip|uxsuccess): [\w\-=,_:\ /.&; \(\)]+( \[.*?\])?.*?
""", self._format_test, log)
return "<pre>%s</pre>" % log
:param title: the title to be displayed
"""
if status.lower() in ("", "failed"):
- icon = 'icon_hide_16.png'
+ icon = '/icon_hide_16.png'
else:
- icon = 'icon_unhide_16.png'
+ icon = '/icon_unhide_16.png'
# trim leading and trailing whitespace
output = output.strip()
return "<span class='old'>%s</span>" % util.dhm_time(age)
return util.dhm_time(age)
- def tree_link(self, myself, tree):
- # return a link to a particular tree
- branch = ""
- if tree in self.buildfarm.trees:
- branch = ":%s" % self.buildfarm.trees[tree].branch
-
- return "<a href='%s?function=Recent+Builds;tree=%s' title='View recent builds for %s'>%s%s</a>" % (myself, tree, tree, tree, branch)
+ def tree_link(self, myself, treename):
+ try:
+ return tree_link(myself, self.buildfarm.trees[treename])
+ except KeyError:
+ return treename
def render(self, output_type):
raise NotImplementedError(self.render)
yield "<div id='log'>"
+ yield "<p><a href='%s/+subunit'>Subunit output</a>" % build_uri(myself, build)
+ try:
+ previous_build = self.buildfarm.builds.get_previous_build(build.tree, build.host, build.compiler, build.revision)
+ except NoSuchBuildError:
+ pass
+ else:
+ yield ", <a href='%s/+subunit-diff/%s'>diff against previous</a>" % (
+ build_uri(myself, build), previous_build.log_checksum())
+ yield "</p>"
+ yield "<p><a href='%s/+stdout'>Standard output (as plain text)</a>, " % build_uri(myself, build)
+ yield "<a href='%s/+stderr'>Standard error (as plain text)</a>" % build_uri(myself, build)
+ yield "</p>"
+
if not plain_logs:
yield "<p>Switch to the <a href='%s?function=View+Build;host=%s;tree=%s"\
";compiler=%s%s;plain=true' title='Switch to bland, non-javascript,"\
all_builds = []
def build_platform(build):
+ host = self.buildfarm.hostdb[build.host]
+ return host.platform.encode("utf-8")
+
+ def build_platform_safe(build):
try:
host = self.buildfarm.hostdb[build.host]
except hostdb.NoSuchHost:
"revision": lambda a, b: cmp(a.revision, b.revision),
"age": lambda a, b: cmp(a.age, b.age),
"host": lambda a, b: cmp(a.host, b.host),
- "platform": lambda a, b: cmp(build_platform(a), build_platform(b)),
+ "platform": lambda a, b: cmp(build_platform_safe(a), build_platform_safe(b)),
"compiler": lambda a, b: cmp(a.compiler, b.compiler),
"status": lambda a, b: cmp(a.status(), b.status()),
}
yield "<tbody>"
for build in all_builds:
- yield "<tr>"
- yield "<td>%s</td>" % util.dhm_time(build.age)
- yield "<td>%s</td>" % revision_link(myself, build.revision, build.tree)
- yield "<td>%s</td>" % build.tree
- yield "<td>%s</td>" % build_platform(build)
- yield "<td>%s</td>" % host_link(myself, build.host)
- yield "<td>%s</td>" % build.compiler
- yield "<td>%s</td>" % build_link(myself, build)
- yield "</tr>"
+ try:
+ build_platform_name = build_platform(build)
+ yield "<tr>"
+ yield "<td>%s</td>" % util.dhm_time(build.age)
+ yield "<td>%s</td>" % revision_link(myself, build.revision, build.tree)
+ yield "<td>%s</td>" % build.tree
+ yield "<td>%s</td>" % build_platform_name
+ yield "<td>%s</td>" % host_link(myself, build.host)
+ yield "<td>%s</td>" % build.compiler
+ yield "<td>%s</td>" % build_link(myself, build)
+ yield "</tr>"
+ except hostdb.NoSuchHost:
+ pass
yield "</tbody></table>"
yield "</div>"
try:
host = self.buildfarm.hostdb[hostname]
except hostdb.NoSuchHost:
- deadhosts.append(hostname)
continue
builds = list(self.buildfarm.get_host_builds(hostname))
if len(builds) > 0:
try:
platform = self.buildfarm.hostdb[host].platform.encode("utf-8")
except hostdb.NoSuchHost:
- platform = "UNKNOWN"
+ continue
yield "<tr><td>%s</td><td>%s</td><td>%s</td></tr>" %\
(host, platform, util.dhm_time(age))
else:
yield "<td>"
yield "%d</td>" % panic_count[tree]
+
try:
lcov_status = self.buildfarm.lcov_status(tree)
except NoSuchBuildError:
self.buildfarm.LCOVHOST, tree, lcov_status)
else:
yield "<td></td>"
+
+ try:
+ unused_fns = self.buildfarm.unused_fns(tree)
+ except NoSuchBuildError:
+ yield "<td></td>"
+ else:
+ if unused_fns is not None:
+ yield "<td><a href=\"/lcov/data/%s/%s/%s\">Unused Functions</a></td>" % (
+ self.buildfarm.LCOVHOST, tree, unused_fns)
+ else:
+ yield "<td></td>"
yield "</tr>"
yield "</tbody></table>"
class DiffPage(HistoryPage):
def render(self, myself, tree, revision):
- t = self.buildfarm.trees[tree]
+ try:
+ t = self.buildfarm.trees[tree]
+ except KeyError:
+ yield "Unknown tree %s" % tree
+ return
branch = t.get_branch()
(entry, diff) = branch.diff(revision)
# get information about the current diff
yield "</div>\n"
yield "</form>\n"
+ def html_page(self, form, lines):
+ yield "<html>\n"
+ yield " <head>\n"
+ yield " <title>samba.org build farm</title>\n"
+ yield " <script language='javascript' src='/build_farm.js'></script>\n"
+ yield " <meta name='keywords' contents='Samba SMB CIFS Build Farm'/>\n"
+ yield " <meta name='description' contents='Home of the Samba Build Farm, the automated testing facility.'/>\n"
+ yield " <meta name='robots' contents='noindex'/>"
+ yield " <link rel='stylesheet' href='/build_farm.css' type='text/css' media='all'/>"
+ yield " <link rel='stylesheet' href='http://www.samba.org/samba/style/common.css' type='text/css' media='all'/>"
+ yield " <link rel='shortcut icon' href='http://www.samba.org/samba/images/favicon.ico'/>"
+ yield " </head>"
+ yield "<body>"
+
+ yield util.FileLoad(os.path.join(webdir, "header2.html"))
+
+ tree = get_param(form, "tree")
+ host = get_param(form, "host")
+ compiler = get_param(form, "compiler")
+ yield "".join(self.main_menu(tree, host, compiler))
+ yield util.FileLoad(os.path.join(webdir, "header3.html"))
+ yield "".join(lines)
+ yield util.FileLoad(os.path.join(webdir, "footer.html"))
+ yield "</body>"
+ yield "</html>"
+
def __call__(self, environ, start_response):
form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)
fn_name = get_param(form, 'function') or ''
start_response('200 OK', [('Content-type', 'text/plain')])
page = ViewSummaryPage(self.buildfarm)
yield "".join(page.render_text(myself))
- else:
+ elif fn_name:
start_response('200 OK', [
('Content-type', 'text/html; charset=utf-8')])
- yield "<html>\n"
- yield " <head>\n"
- yield " <title>samba.org build farm</title>\n"
- yield " <script language='javascript' src='/build_farm.js'></script>\n"
- yield " <meta name='keywords' contents='Samba SMB CIFS Build Farm'/>\n"
- yield " <meta name='description' contents='Home of the Samba Build Farm, the automated testing facility.'/>\n"
- yield " <meta name='robots' contents='noindex'/>"
- yield " <link rel='stylesheet' href='/build_farm.css' type='text/css' media='all'/>"
- yield " <link rel='stylesheet' href='http://master.samba.org/samba/style/common.css' type='text/css' media='all'/>"
- yield " <link rel='shortcut icon' href='http://www.samba.org/samba/images/favicon.ico'/>"
- yield " </head>"
- yield "<body>"
-
- yield util.FileLoad(os.path.join(webdir, "header2.html"))
tree = get_param(form, "tree")
host = get_param(form, "host")
compiler = get_param(form, "compiler")
- yield "".join(self.main_menu(tree, host, compiler))
- yield util.FileLoad(os.path.join(webdir, "header3.html"))
+
if fn_name == "View_Build":
plain_logs = (get_param(form, "plain") is not None and get_param(form, "plain").lower() in ("yes", "1", "on", "true", "y"))
revision = get_param(form, "revision")
else:
page = ViewBuildPage(self.buildfarm)
plain_logs = (get_param(form, "plain") is not None and get_param(form, "plain").lower() in ("yes", "1", "on", "true", "y"))
- yield "".join(page.render(myself, build, plain_logs))
+ yield "".join(self.html_page(form, page.render(myself, build, plain_logs)))
elif fn_name == "View_Host":
page = ViewHostPage(self.buildfarm)
- yield "".join(page.render_html(myself, get_param(form, 'host')))
+ yield "".join(self.html_page(form, page.render_html(myself, get_param(form, 'host'))))
elif fn_name == "Recent_Builds":
page = ViewRecentBuildsPage(self.buildfarm)
- yield "".join(page.render(myself, get_param(form, "tree"), get_param(form, "sortby") or "age"))
+ yield "".join(self.html_page(form, page.render(myself, get_param(form, "tree"), get_param(form, "sortby") or "age")))
elif fn_name == "Recent_Checkins":
# validate the tree
author = get_param(form, 'author')
page = RecentCheckinsPage(self.buildfarm)
- yield "".join(page.render(myself, tree, author))
+ yield "".join(self.html_page(form, page.render(myself, tree, author)))
elif fn_name == "diff":
revision = get_param(form, 'revision')
page = DiffPage(self.buildfarm)
- yield "".join(page.render(myself, tree, revision))
+ yield "".join(self.html_page(form, page.render(myself, tree, revision)))
+ elif fn_name == "Summary":
+ page = ViewSummaryPage(self.buildfarm)
+ yield "".join(self.html_page(form, page.render_html(myself)))
else:
- fn = wsgiref.util.shift_path_info(environ)
- if fn == "recent":
+ yield "Unknown function %s" % fn_name
+ else:
+ fn = wsgiref.util.shift_path_info(environ)
+ if fn == "tree":
+ tree = wsgiref.util.shift_path_info(environ)
+ subfn = wsgiref.util.shift_path_info(environ)
+ if subfn in ("", None, "+recent"):
+ start_response('200 OK', [
+ ('Content-type', 'text/html; charset=utf-8')])
page = ViewRecentBuildsPage(self.buildfarm)
- yield "".join(page.render(myself, wsgiref.util.shift_path_info(environ), get_param(form, 'sortby') or 'age'))
- elif fn == "host":
- page = ViewHostPage(self.buildfarm)
- yield "".join(page.render_html(myself, wsgiref.util.shift_path_info(environ)))
- elif fn == "build":
- build_checksum = wsgiref.util.shift_path_info(environ)
- build = self.buildfarm.builds.get_by_checksum(build_checksum)
- page = ViewBuildPage(self.buildfarm)
- subfn = wsgiref.util.shift_path_info(environ)
- if subfn == "+plain":
- yield "".join(page.render(myself, build, True))
- elif subfn == "+subunit":
- try:
- yield build.read_subunit().read()
- except NoTestOutput:
- yield "There was no test output"
- elif subfn == "":
- yield "".join(page.render(myself, build, False))
- elif fn == "":
- page = ViewSummaryPage(self.buildfarm)
- yield "".join(page.render_html(myself))
+ yield "".join(self.html_page(form, page.render(myself, tree, get_param(form, 'sortby') or 'age')))
+ elif subfn == "+recent-ids":
+ start_response('200 OK', [
+ ('Content-type', 'text/plain; charset=utf-8')])
+ yield "".join([x.log_checksum()+"\n" for x in self.buildfarm.get_tree_builds(tree) if x.has_log()])
else:
- yield "Unknown function %s" % fn
- yield util.FileLoad(os.path.join(webdir, "footer.html"))
- yield "</body>"
- yield "</html>"
+ start_response('200 OK', [
+ ('Content-type', 'text/html; charset=utf-8')])
+ yield "Unknown subfn %s" % subfn
+ elif fn == "host":
+ start_response('200 OK', [
+ ('Content-type', 'text/html; charset=utf-8')])
+ page = ViewHostPage(self.buildfarm)
+ yield "".join(self.html_page(form, page.render_html(myself, wsgiref.util.shift_path_info(environ))))
+ elif fn == "build":
+ build_checksum = wsgiref.util.shift_path_info(environ)
+ try:
+ build = self.buildfarm.builds.get_by_checksum(build_checksum)
+ except NoSuchBuildError:
+ start_response('404 Page Not Found', [
+ ('Content-Type', 'text/html; charset=utf8')])
+ yield "No build with checksum %s found" % build_checksum
+ return
+ page = ViewBuildPage(self.buildfarm)
+ subfn = wsgiref.util.shift_path_info(environ)
+ if subfn == "+plain":
+ start_response('200 OK', [
+ ('Content-type', 'text/html; charset=utf-8')])
+ yield "".join(page.render(myself, build, True))
+ elif subfn == "+subunit":
+ start_response('200 OK', [
+ ('Content-type', 'text/x-subunit; charset=utf-8'),
+ ('Content-Disposition', 'attachment; filename="%s.%s.%s-%s.subunit"' % (build.tree, build.host, build.compiler, build.revision))])
+ try:
+ yield build.read_subunit().read()
+ except NoTestOutput:
+ yield "There was no test output"
+ elif subfn == "+stdout":
+ start_response('200 OK', [
+ ('Content-type', 'text/plain; charset=utf-8'),
+ ('Content-Disposition', 'attachment; filename="%s.%s.%s-%s.log"' % (build.tree, build.host, build.compiler, build.revision))])
+ yield build.read_log().read()
+ elif subfn == "+stderr":
+ start_response('200 OK', [
+ ('Content-type', 'text/plain; charset=utf-8'),
+ ('Content-Disposition', 'attachment; filename="%s.%s.%s-%s.err"' % (build.tree, build.host, build.compiler, build.revision))])
+ yield build.read_err().read()
+ elif subfn == "+subunit-diff":
+ start_response('200 OK', [
+ ('Content-type', 'text/plain; charset=utf-8')])
+ subunit_this = build.read_subunit().readlines()
+ other_build_checksum = wsgiref.util.shift_path_info(environ)
+ other_build = self.buildfarm.builds.get_by_checksum(other_build_checksum)
+ subunit_other = other_build.read_subunit().readlines()
+ import difflib
+ yield "".join(difflib.unified_diff(subunit_other, subunit_this))
+
+ elif subfn in ("", None):
+ start_response('200 OK', [
+ ('Content-type', 'text/html; charset=utf-8')])
+ yield "".join(self.html_page(form, page.render(myself, build, False)))
+ elif fn in ("", None):
+ start_response('200 OK', [
+ ('Content-type', 'text/html; charset=utf-8')])
+ page = ViewSummaryPage(self.buildfarm)
+ yield "".join(self.html_page(form, page.render_html(myself)))
+ else:
+ start_response('404 Page Not Found', [
+ ('Content-type', 'text/html; charset=utf-8')])
+ yield "Unknown function %s" % fn
if __name__ == '__main__':