[cig-commits] r12649 - cs/buildbot/trunk/buildbot/status

leif at geodynamics.org leif at geodynamics.org
Fri Aug 15 14:59:07 PDT 2008


Author: leif
Date: 2008-08-15 14:59:07 -0700 (Fri, 15 Aug 2008)
New Revision: 12649

Modified:
   cs/buildbot/trunk/buildbot/status/html.py
Log:
BBL rendering fix: wrap regular files in HTML.


Modified: cs/buildbot/trunk/buildbot/status/html.py
===================================================================
--- cs/buildbot/trunk/buildbot/status/html.py	2008-08-15 21:26:01 UTC (rev 12648)
+++ cs/buildbot/trunk/buildbot/status/html.py	2008-08-15 21:59:07 UTC (rev 12649)
@@ -764,6 +764,7 @@
     subscribed = False
     membername = None
     data = ""
+    textWrapper = False
 
     def __init__(self, original):
         Resource.__init__(self)
@@ -835,10 +836,17 @@
     def setContentType(self, request):
         import mimetypes
         if self.membername:
+            # Assume directories don't have confusing extensions.
             ctype, encoding = mimetypes.guess_type(self.membername)
             if ctype is not None and encoding is None:
                 request.setHeader("content-type", ctype)
             else:
+                # The member is a directory or a regular file (here,
+                # we can't discover which one it is, since we don't
+                # have access to the data yet).  Assume regular files
+                # are text.  But since directories are rendered as
+                # HTML, regular files must also be rendered as such.
+                self.textWrapper = True
                 request.setHeader("content-type", "text/html")
             return
         ctype, encoding = mimetypes.guess_type(self.original.getName())
@@ -896,8 +904,12 @@
                 pass
 
         if tarinfo.isreg():
+            if self.textWrapper:
+                self.req.write('<html><head><title>%s</title></head><body><p><pre>' % self.membername)
             dataStream = bbl.extractfile(tarinfo)
             copyfileobj(dataStream, self.req)
+            if self.textWrapper:
+                self.req.write('</pre></p></body></html>')
         elif tarinfo.isdir():
             data = '<html><head><title>%s</title></head><body><ul>' % self.membername
             for name in bbl.getnames():



More information about the cig-commits mailing list