[Buildbot-commits] buildbot/buildbot/status/web baseweb.py, 1.1, 1.2 waterfall.py, 1.3, 1.4

Brian Warner warner at users.sourceforge.net
Wed Aug 1 22:08:07 UTC 2007


Update of /cvsroot/buildbot/buildbot/buildbot/status/web
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28929/buildbot/status/web

Modified Files:
	baseweb.py waterfall.py 
Log Message:
[project @ checkpoint some web-parts changes, not really complete]

Original author: warner at lothar.com
Date: 2007-07-30 02:50:15+00:00

Index: baseweb.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/baseweb.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- baseweb.py	1 Aug 2007 22:07:54 -0000	1.1
+++ baseweb.py	1 Aug 2007 22:08:05 -0000	1.2
@@ -14,10 +14,15 @@
 
 class ImprovedWaterfall(WaterfallStatusResource):
     def __init__(self):
-        HtmlResource.__init__(self)
+        WaterfallStatusResource.__init__(self, css="/buildbot.css")
+
+    def getStatus(self, request):
+        return request.site.status
+    def getControl(self, request):
+        return request.site.control
+    def getChangemaster(self, request):
+        return request.site.changemaster
 
-    def render(self, request):
-        status = request.site.status
 
 HEADER = '''
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
@@ -37,7 +42,8 @@
 class WebStatus(service.MultiService):
     implements(IStatusReceiver)
 
-    def __init__(self, http_port=None, distrib_port=None, allowForce=False):
+    def __init__(self, http_port=None, distrib_port=None, allowForce=False,
+                 css=None):
         service.MultiService.__init__(self)
         if type(http_port) is int:
             http_port = "tcp:%d" % http_port
@@ -59,6 +65,7 @@
         self.site = server.Site(self.root)
         self.site.header = HEADER
         self.site.footer = FOOTER
+        self.site.css = css
 
         if self.http_port is not None:
             s = strports.service(self.http_port, self.site)
@@ -72,7 +79,7 @@
         r = static.Data("This tree contains the built-in status pages\n",
                         "text/plain")
         self.root.putChild("_buildbot", r)
-        #r.putChild("waterfall", WaterfallStatusResource
+        r.putChild("waterfall", ImprovedWaterfall())
         r.putChild("one_line_per_build", OneLinePerBuild())
 
     def getStatus(self):
@@ -86,15 +93,15 @@
         self.setup()
 
     def setup(self):
-        status = self.parent.getStatus()
+        self.site.status = self.parent.getStatus()
         if self.allowForce:
-            control = IControl(self.parent)
+            self.site.control = IControl(self.parent)
         else:
-            control = None
+            self.site.control = None
+        self.site.changemaster = self.parent.change_svc
         self.site.webstatus = self # TODO: why?
-        self.site.status = status
-        self.site.control = control
         self.site.basedir = self.parent.basedir # TODO: also why?
+        # maybe self.site.head_stuff, to add to <head>
 
 # resources can get access to the site with request.site
 
@@ -105,6 +112,7 @@
     css = None
     contentType = "text/html; charset=UTF-8"
     title = "Dummy"
+    depth = None # must be specified
 
     def render(self, request):
         data = self.content(request)
@@ -116,12 +124,22 @@
             return ''
         return data
 
+    def getCSSlink(self, request):
+        css = request.site.css # might be None
+        if not css:
+            return None
+        url = "/".join([".." * self.depth] + [css])
+        link = '  <link href="%s" rel="stylesheet" type="text/css"/>\n' % url
+        return url
     def make_head(self, request):
         data = ""
         data += '  <title>%s</title>\n' % self.title
         # TODO: use some sort of relative link up to the root page, so
         # this css can be used from child pages too
-        data += '  <link href="/buildbot.css" rel="stylesheet" type="text/css"/>\n'
+        csslink = self.getCSSlink(request)
+        if csslink:
+            data += csslink
+        # TODO: favicon
         return data
 
     def content(self, request):

Index: waterfall.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/waterfall.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- waterfall.py	1 Aug 2007 20:31:33 -0000	1.3
+++ waterfall.py	1 Aug 2007 22:08:05 -0000	1.4
@@ -155,6 +155,9 @@
             return ''
         return data
 
+    def getTitle(self, request):
+        return self.title
+
     def content(self, request):
         data = ('<!DOCTYPE html PUBLIC'
                 ' "-//W3C//DTD XHTML 1.0 Transitional//EN"\n'
@@ -164,7 +167,7 @@
                 ' lang="en"'
                 ' xml:lang="en">\n')
         data += "<head>\n"
-        data += "  <title>" + self.title + "</title>\n"
+        data += "  <title>" + self.getTitle(request) + "</title>\n"
         if self.css:
             # TODO: use some sort of relative link up to the root page, so
             # this css can be used from child pages too
@@ -1038,30 +1041,41 @@
 class WaterfallStatusResource(HtmlResource):
     """This builds the main status page, with the waterfall display, and
     all child pages."""
-    title = "BuildBot"
-    def __init__(self, status, changemaster, categories, css=None):
+
+    def __init__(self, categories=None, css=None):
         HtmlResource.__init__(self)
-        self.status = status
-        self.changemaster = changemaster
         self.categories = categories
-        p = self.status.getProjectName()
-        if p:
-            self.title = "BuildBot: %s" % p
         self.css = css
 
+    def getTitle(self, request):
+        status = self.getStatus(request)
+        p = status.getProjectName()
+        if p:
+            return "BuildBot: %s" % p
+        else:
+            return "BuildBot"
+
+    def getStatus(self, request):
+        return self.status
+    def getControl(self, request):
+        return self.control
+    def getChangemaster(self, request):
+        return self.changemaster
+
     def body(self, request):
         "This method builds the main waterfall display."
 
+        status = self.getStatus(request)
         data = ''
 
-        projectName = self.status.getProjectName()
-        projectURL = self.status.getProjectURL()
+        projectName = status.getProjectName()
+        projectURL = status.getProjectURL()
 
         phase = request.args.get("phase",["2"])
         phase = int(phase[0])
 
         showBuilders = request.args.get("show", None)
-        allBuilders = self.status.getBuilderNames(categories=self.categories)
+        allBuilders = status.getBuilderNames(categories=self.categories)
         if showBuilders:
             builderNames = []
             for b in showBuilders:
@@ -1072,7 +1086,7 @@
                 builderNames.append(b)
         else:
             builderNames = allBuilders
-        builders = map(lambda name: self.status.getBuilder(name),
+        builders = map(lambda name: status.getBuilder(name),
                        builderNames)
 
         if phase == -1:
@@ -1101,7 +1115,7 @@
         data += ' <tr class="Activity">\n'
         data += td('current activity', align='right', colspan=2)
         for b in builders:
-            box = ICurrentBox(b).getBox(self.status)
+            box = ICurrentBox(b).getBox(status)
             data += box.td(align="center")
         data += " </tr>\n"
         
@@ -1202,7 +1216,7 @@
         # (commit, all builders) if they have any events there. Build up the
         # array of events, and stop when we have a reasonable number.
             
-        commit_source = self.changemaster
+        commit_source = self.getChangemaster(request)
 
         lastEventTime = util.now()
         sources = [commit_source] + builders
@@ -1528,10 +1542,11 @@
         self.status = status
         self.control = control
         self.changemaster = changemaster
-        self.categories = categories
         self.css = css
-        waterfall = WaterfallStatusResource(self.status, changemaster,
-                                            categories, css)
+        waterfall = WaterfallStatusResource(categories, css)
+        waterfall.status = self.status
+        waterfall.control = control
+        waterfall.changemaster = changemaster
         self.putChild("", waterfall)
 
     def render(self, request):





More information about the Commits mailing list