[Buildbot-commits] buildbot/buildbot/status/web base.py, 1.14, 1.15 baseweb.py, 1.25, 1.26 builder.py, 1.10, 1.11 classic.css, 1.1, 1.2

Brian Warner warner at users.sourceforge.net
Sun Sep 30 09:23:59 UTC 2007


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

Modified Files:
	base.py baseweb.py builder.py classic.css 
Log Message:
[project @ web: refactor OneLineMixin, add some CSS]

Original author: warner at lothar.com
Date: 2007-09-30 08:57:37+00:00

Index: base.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/base.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- base.py	30 Sep 2007 01:53:22 -0000	1.14
+++ base.py	30 Sep 2007 09:23:57 -0000	1.15
@@ -1,5 +1,5 @@
 
-import urlparse, urllib
+import urlparse, urllib, time
 from zope.interface import Interface
 from twisted.web import html, resource
 from buildbot.status import builder
@@ -294,3 +294,42 @@
     if age < 2*MONTH:
         return "about %s ago" % plural("week", "weeks", age / WEEK)
     return "a long time ago"
+
+
+class OneLineMixin:
+    LINE_TIME_FORMAT = "%b %d %H:%M"
+
+    def make_line(self, req, build, include_builder=True):
+        builder_name = build.getBuilder().getName()
+        results = build.getResults()
+        try:
+            rev = build.getProperty("got_revision")
+            if rev is None:
+                rev = "??"
+        except KeyError:
+            rev = "??"
+        if len(rev) > 20:
+            rev = "version is too-long"
+        root = self.path_to_root(req)
+        values = {'class': css_classes[results],
+                  'builder_name': builder_name,
+                  'buildnum': build.getNumber(),
+                  'results': css_classes[results],
+                  'buildurl': (root +
+                               "builders/%s/builds/%d" % (builder_name,
+                                                          build.getNumber())),
+                  'builderurl': (root + "builders/%s" % builder_name),
+                  'rev': rev,
+                  'time': time.strftime(self.LINE_TIME_FORMAT,
+                                        time.localtime(build.getTimes()[0])),
+                  }
+
+        fmt_pieces = ['<font size="-1">(%(time)s)</font>',
+                      'rev=[%(rev)s]',
+                      '<span class="%(class)s">%(results)s</span>',
+                      ]
+        if include_builder:
+            fmt_pieces.append('<a href="%(builderurl)s">%(builder_name)s</a>')
+        fmt_pieces.append('<a href="%(buildurl)s">#%(buildnum)d</a>:')
+        data = " ".join(fmt_pieces) % values
+        return data

Index: baseweb.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/baseweb.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- baseweb.py	30 Sep 2007 01:53:22 -0000	1.25
+++ baseweb.py	30 Sep 2007 09:23:57 -0000	1.26
@@ -1,5 +1,5 @@
 
-import os, sys, time, urllib, weakref
+import os, sys, urllib, weakref
 from itertools import count
 
 from zope.interface import implements
@@ -10,7 +10,8 @@
 
 from buildbot.interfaces import IControl, IStatusReceiver
 
-from buildbot.status.web.base import HtmlResource, css_classes, Box, build_get_class, ICurrentBox
+from buildbot.status.web.base import HtmlResource, Box, \
+     build_get_class, ICurrentBox, OneLineMixin
 from buildbot.status.web.waterfall import WaterfallStatusResource
 from buildbot.status.web.changes import ChangesResource
 from buildbot.status.web.builder import BuildersResource
@@ -64,43 +65,6 @@
     return [e[2] for e in events[-numbuilds:]]
 
 
-class OneLineMixin:
-    LINE_TIME_FORMAT = "%b %d %H:%M"
-
-    def make_line(self, req, build):
-        builder_name = build.getBuilder().getName()
-        results = build.getResults()
-        try:
-            rev = build.getProperty("got_revision")
-            if rev is None:
-                rev = "??"
-        except KeyError:
-            rev = "??"
-        if len(rev) > 20:
-            rev = "version is too-long"
-        root = self.path_to_root(req)
-        values = {'class': css_classes[results],
-                  'builder_name': builder_name,
-                  'buildnum': build.getNumber(),
-                  'results': css_classes[results],
-                  'buildurl': (root +
-                               "builders/%s/builds/%d" % (builder_name,
-                                                          build.getNumber())),
-                  'builderurl': (root + "builders/%s" % builder_name),
-                  'rev': rev,
-                  'time': time.strftime(self.LINE_TIME_FORMAT,
-                                        time.localtime(build.getTimes()[0])),
-                  }
-
-        fmt = ('<font size="-1">(%(time)s)</font> '
-               '<a href="%(builderurl)s">%(builder_name)s</a> '
-               'rev=[%(rev)s] '
-               '<a href="%(buildurl)s">#%(buildnum)d</a>: '
-               '<span class="%(class)s">%(results)s</span> '
-               )
-        data = fmt % values
-        return data
-
 # /one_line_per_build
 #  accepts builder=, branch=, numbuilds=
 class OneLinePerBuild(HtmlResource, OneLineMixin):
@@ -134,7 +98,8 @@
         data = ""
 
         # really this is "up to %d builds"
-        data += "<h1>Last %d finished builds</h1>\n" % numbuilds
+        data += "<h1>Last %d finished builds: %s</h1>\n" % \
+                (numbuilds, " ".join(branches))
         if builders:
             data += ("<p>of builders: %s</p>\n" % (", ".join(builders)))
         data += "<ul>\n"
@@ -204,12 +169,12 @@
 
         data = ""
 
-        data += "<h2>Latest builds</h2>\n"
+        data += "<h2>Latest builds: %s</h2>\n" % " ".join(branches)
         data += "<table>\n"
         for bn in builders:
             builder = status.getBuilder(bn)
             data += "<tr>\n"
-            data += "<td>%s</td>\n" % html.escape(bn)
+            data += '<td class="box">%s</td>\n' % html.escape(bn)
             builds = list(builder.generateFinishedBuilds(branches,
                                                          num_builds=1))
             if builds:
@@ -227,10 +192,10 @@
                 text = ['<a href="%s">%s</a>' % (url, label)]
                 text.extend(b.getText())
                 box = Box(text, b.getColor(),
-                          class_="LastBuild %s" % build_get_class(b))
+                          class_="LastBuild box %s" % build_get_class(b))
                 data += box.td(align="center")
             else:
-                data += "<td></td>\n"
+                data += '<td class="LastBuild box" >no build</td>\n'
             current_box = ICurrentBox(builder).getBox(status)
             data += current_box.td(align="center")
         data += "</table>\n"

Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/builder.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- builder.py	28 Sep 2007 09:33:31 -0000	1.10
+++ builder.py	30 Sep 2007 09:23:57 -0000	1.11
@@ -6,14 +6,14 @@
 import re, urllib, time
 from twisted.python import log
 from buildbot import interfaces
-from buildbot.status.web.base import HtmlResource, make_row, css_classes
+from buildbot.status.web.base import HtmlResource, make_row, OneLineMixin
 from buildbot.process.base import BuildRequest
 from buildbot.sourcestamp import SourceStamp
 
 from buildbot.status.web.build import BuildsResource
 
 # /builders/$builder
-class StatusResourceBuilder(HtmlResource):
+class StatusResourceBuilder(HtmlResource, OneLineMixin):
     addSlash = True
 
     def __init__(self, builder_status, builder_control):
@@ -36,15 +36,6 @@
         data += "[%s]" % build.getCurrentStep().getName()
         return data
 
-    def build_finished_line(self, build, req):
-        buildnum = build.getNumber()
-        buildurl = req.childLink("builds/%d" % buildnum)
-        results = build.getResults()
-        text = " ".join(build.getText())
-        data = '<a href="%s">#%d</a> ' % (buildurl, buildnum)
-        data += '<span class="%s">%s</span>' % (css_classes[results], text)
-        return data
-
     def body(self, req):
         b = self.builder_status
         control = self.builder_control
@@ -77,7 +68,7 @@
         data += "<h2>Recent Builds:</h2>\n"
         data += "<ul>\n"
         for i,build in enumerate(b.generateFinishedBuilds(num_builds=5)):
-            data += " <li>" + self.build_finished_line(build, req) + "</li>\n"
+            data += " <li>" + self.make_line(req, build, False) + "</li>\n"
             if i == 0:
                 data += "<br />\n" # separator
                 # TODO: or empty list?

Index: classic.css
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/classic.css,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- classic.css	27 Feb 2007 23:07:16 -0000	1.1
+++ classic.css	30 Sep 2007 09:23:57 -0000	1.2
@@ -7,6 +7,10 @@
     border-right: 1px solid;
 }
 
+td.box {
+       border: 1px solid;
+}
+
 /* Activity states */
 .offline { 
         background-color: red;





More information about the Commits mailing list