+ 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(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:
+ 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 ("", "limit", None):
+ if subfn == "limit":
+ try:
+ limit = int(wsgiref.util.shift_path_info(environ))
+ except:
+ limit = 10
+ else:
+ limit = 10
+ start_response('200 OK', [
+ ('Content-type', 'text/html; charset=utf-8')])
+ yield "".join(self.html_page(form, page.render(myself, build, False, limit)))
+ elif fn in ("", None):
+ start_response('200 OK', [
+ ('Content-type', 'text/html; charset=utf-8')])