Fix image urls.
[amitay/build-farm.git] / buildfarm / web / __init__.py
index b8ef478b9eacfed1218302dbe3e9933a2868bee5..f58cb9a699cb98ee8a3066a93870706c4975cde8 100755 (executable)
@@ -313,9 +313,9 @@ def make_collapsible_html(type, title, output, id, status=""):
     :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()
@@ -466,6 +466,11 @@ class ViewBuildPage(BuildFarmPage):
 
         yield "<div id='log'>"
 
+        yield "<p><a href='%s/+subunit'>Subunit output</a></p>" % build_uri(myself, build)
+        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,"\
@@ -920,7 +925,7 @@ class BuildFarmApp(object):
             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')])
 
@@ -957,38 +962,68 @@ class BuildFarmApp(object):
                 revision = get_param(form, 'revision')
                 page = DiffPage(self.buildfarm)
                 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 == "tree":
-                    tree = wsgiref.util.shift_path_info(environ)
-                    subfn = wsgiref.util.shift_path_info(environ)
-                    if subfn in ("", None, "+recent"):
-                        page = ViewRecentBuildsPage(self.buildfarm)
-                        yield "".join(self.html_page(form, page.render(myself, tree, get_param(form, 'sortby') or 'age')))
-                    else:
-                        yield "Unknown subfn %s" % subfn
-                elif fn == "host":
-                    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)
-                    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 in ("", None):
-                        yield "".join(self.html_page(form, page.render(myself, build, False)))
-                elif fn in ("", None):
-                    page = ViewSummaryPage(self.buildfarm)
-                    yield "".join(self.html_page(form, page.render_html(myself)))
+                yield "Unknown function %s" % fn_name
+        else:
+            fn = wsgiref.util.shift_path_info(environ)
+            if fn == "tree":
+                start_response('200 OK', [
+                    ('Content-type', 'text/html; charset=utf-8')])
+                tree = wsgiref.util.shift_path_info(environ)
+                subfn = wsgiref.util.shift_path_info(environ)
+                if subfn in ("", None, "+recent"):
+                    page = ViewRecentBuildsPage(self.buildfarm)
+                    yield "".join(self.html_page(form, page.render(myself, tree, get_param(form, 'sortby') or 'age')))
                 else:
-                    yield "Unknown function %s" % fn
+                    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)
+                build = self.buildfarm.builds.get_by_checksum(build_checksum)
+                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 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__':