[Buildbot-commits] buildbot/buildbot/status html.py,1.52,1.53

Brian Warner warner at users.sourceforge.net
Tue Apr 19 08:22:44 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/status
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19858/buildbot/status

Modified Files:
	html.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-49
Creator:  Brian Warner <warner at monolith.lothar.com>

add favicon.ico, remove some deprecated web tests

2005-04-19  Brian Warner  <warner at lothar.com>

   * buildbot/slave/commands.py (ShellCommand._startCommand): log the
   environment used by the command, at least on the child side.

   * buildbot/status/html.py (TextLog.pauseProducing): add a note,
   this method needs to be added and implemented because it gets
   called under heavy load. I don't quite understand the
   producer/consumer API enough to write it.
   (StatusResource.getChild): add a resource for /favicon.ico
   (Waterfall.__init__): add favicon= argument
   * buildbot/test/test_web.py (WebTest.test_waterfall): test it
   (WebTest.test_webPortnum): stop using deprecated 'webPortnum'
   (WebTest.test_webPathname): same
   (WebTest.test_webPathname_port): same
   * docs/config.xhtml: mention favicon=
   * buildbot/buildbot.png: add a default icon, dorky as it is


Index: html.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/html.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- html.py	19 Apr 2005 07:45:19 -0000	1.52
+++ html.py	19 Apr 2005 08:22:42 -0000	1.53
@@ -3,6 +3,7 @@
 from __future__ import generators
 
 from twisted.python import log, components
+from twisted.python.util import sibpath
 import urllib
 
 from twisted.internet import defer, reactor
@@ -13,7 +14,7 @@
 from twisted.application import service, internet
 from twisted.spread import pb
 
-import string, types, time
+import string, types, time, os.path
 
 from buildbot import interfaces, util
 from buildbot import version
@@ -565,6 +566,12 @@
         d = self.original.waitUntilFinished()
         d.addCallback(self.finished)
 
+    # TODO: under heavy load (a rogue web crawler hammering all the build log
+    # pages), this method gets called, and we don't implement it, which is
+    # bad.
+    #def pauseProducing(self):
+    #    pass
+
     def stopProducing(self):
         pass
 
@@ -1255,6 +1262,7 @@
 class StatusResource(Resource):
     status = None
     control = None
+    favicon = None
 
     def __init__(self, status, control, changemaster):
         """
@@ -1282,8 +1290,14 @@
             return StatusResourceBuilder(builder, control)
         if path == "changes":
             return StatusResourceChanges(self.changemaster)
+        if path == "favicon.ico":
+            if self.favicon:
+                return static.File(self.favicon)
+            return NoResource("No favicon.ico registered")
         return NoResource("No such Builder '%s'" % path)
 
+# TODO: this hack probably doesn't work under windows
+buildbot_icon = os.path.abspath(sibpath(__file__, "../buildbot.png"))
 
 class Waterfall(service.MultiService, util.ComparableMixin):
     """I implement the primary web-page status interface, called a 'Waterfall
@@ -1308,7 +1322,8 @@
                       service.MultiService.__implements__)
     compare_attrs = ["http_port", "distrib_port", "allowForce"]
 
-    def __init__(self, http_port=None, distrib_port=None, allowForce=True):
+    def __init__(self, http_port=None, distrib_port=None, allowForce=True,
+                 favicon=buildbot_icon):
         """
 
         xxxTo have the buildbot run its own web server, pass a port number to
@@ -1337,12 +1352,23 @@
                            per-Builder page that allows visitors to the web
                            site to initiate a build. If False, don't provide
                            this button.
+
+        @type  favicon: string
+        @param favicon: if set, provide the pathname of an image file that
+                        will be used for the 'favicon.ico' resource. Many
+                        browsers automatically request this file and use it
+                        as an icon in any bookmark generated from this site.
+                        Defaults to the L{buildbot.png} image provided in the
+                        distribution. Can be set to None to avoid using
+                        a favicon at all.
+                        
         """
         service.MultiService.__init__(self)
         assert allowForce in (True, False) # TODO: implement others
         self.http_port = http_port
         self.distrib_port = distrib_port
         self.allowForce = allowForce
+        self.favicon = favicon
 
     def __repr__(self):
         if self.http_port is None:
@@ -1366,7 +1392,9 @@
         else:
             control = None
         change_svc = self.parent.change_svc
-        self.site = server.Site(StatusResource(status, control, change_svc))
+        sr = StatusResource(status, control, change_svc)
+        sr.favicon = self.favicon
+        self.site = server.Site(sr)
 
         if self.http_port is not None:
             s = internet.TCPServer(self.http_port, self.site)





More information about the Commits mailing list