[Buildbot-commits] buildbot/buildbot/status/web base.py, 1.21, 1.22 baseweb.py, 1.31, 1.32 builder.py, 1.16, 1.17

Brian Warner warner at users.sourceforge.net
Wed Nov 21 09:24:21 UTC 2007


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

Modified Files:
	base.py baseweb.py builder.py 
Log Message:
[project @ more #138: add buttons to force/stop-builds on all Builders at once]

Original author: warner at lothar.com
Date: 2007-11-21 09:12:29+00:00

Index: base.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/base.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- base.py	21 Nov 2007 09:23:34 -0000	1.21
+++ base.py	21 Nov 2007 09:24:18 -0000	1.22
@@ -53,10 +53,15 @@
     label = html.escape(label)
     return ROW_TEMPLATE % {"label": label, "field": field}
 
-def make_stop_form(stopURL):
-    data = """<form action="%s" class='command stopbuild'>
-      <p>To stop this build, fill out the following fields and
-      click the 'Stop' button</p>\n""" % stopURL
+def make_stop_form(stopURL, on_all=False):
+    if on_all:
+        data = """<form action="%s" class='command stopbuild'>
+          <p>To stop all builds, fill out the following fields and
+          push the 'Stop' button</p>\n""" % stopURL
+    else:
+        data = """<form action="%s" class='command stopbuild'>
+          <p>To stop this build, fill out the following fields and
+          push the 'Stop' button</p>\n""" % stopURL
     data += make_row("Your name:",
                      "<input type='text' name='username' />")
     data += make_row("Reason for stopping build:",
@@ -64,10 +69,15 @@
     data += '<input type="submit" value="Stop Builder" /></form>\n'
     return data
 
-def make_force_build_form(forceURL):
-    data = """<form action="%s" class="command forcebuild">
-      <p>To force a build, fill out the following fields and
-      click the 'Force Build' button</p>""" % forceURL
+def make_force_build_form(forceURL, on_all=False):
+    if on_all:
+        data = """<form action="%s" class="command forcebuild">
+          <p>To force a build on all Builders, fill out the following fields
+          and push the 'Force Build' button</p>""" % forceURL
+    else:
+        data = """<form action="%s" class="command forcebuild">
+          <p>To force a build, fill out the following fields and
+          push the 'Force Build' button</p>""" % forceURL
     return (data
       + make_row("Your name:",
                  "<input type='text' name='username' />")

Index: baseweb.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/baseweb.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- baseweb.py	1 Oct 2007 01:06:51 -0000	1.31
+++ baseweb.py	21 Nov 2007 09:24:18 -0000	1.32
@@ -11,7 +11,8 @@
 from buildbot.interfaces import IControl, IStatusReceiver
 
 from buildbot.status.web.base import HtmlResource, Box, \
-     build_get_class, ICurrentBox, OneLineMixin, map_branches
+     build_get_class, ICurrentBox, OneLineMixin, map_branches, \
+     make_stop_form, make_force_build_form
 from buildbot.status.web.waterfall import WaterfallStatusResource
 from buildbot.status.web.changes import ChangesResource
 from buildbot.status.web.builder import BuildersResource
@@ -105,12 +106,28 @@
             data += ("<p>of builders: %s</p>\n" % (", ".join(builders)))
         data += "<ul>\n"
         got = 0
+        building = False
+        online = 0
         for build in g:
             got += 1
             data += " <li>" + self.make_line(req, build) + "</li>\n"
+            builder_status = build.getBuilder().getState()[0]
+            if builder_status == "building":
+                building = True
+                online += 1
+            elif builder_status != "offline":
+                online += 1
         if not got:
             data += " <li>No matching builds found</li>\n"
         data += "</ul>\n"
+
+        if building:
+            stopURL = "builders/_all/stop"
+            data += make_stop_form(stopURL, True)
+        if online:
+            forceURL = "builders/_all/force"
+            data += make_force_build_form(forceURL, True)
+
         return data
 
 
@@ -165,7 +182,7 @@
 
     def body(self, req):
         status = self.getStatus(req)
-        
+
         builders = req.args.get("builder", status.getBuilderNames())
         branches = [b for b in req.args.get("branch", []) if b]
 
@@ -173,6 +190,9 @@
 
         data += "<h2>Latest builds: %s</h2>\n" % ", ".join(branches)
         data += "<table>\n"
+
+        building = False
+        online = 0
         for bn in builders:
             builder = status.getBuilder(bn)
             data += "<tr>\n"
@@ -200,7 +220,23 @@
                 data += '<td class="LastBuild box" >no build</td>\n'
             current_box = ICurrentBox(builder).getBox(status)
             data += current_box.td(align="center")
+
+            builder_status = builder.getState()[0]
+            if builder_status == "building":
+                building = True
+                online += 1
+            elif builder_status != "offline":
+                online += 1
+
         data += "</table>\n"
+
+        if building:
+            stopURL = "builders/_all/stop"
+            data += make_stop_form(stopURL, True)
+        if online:
+            forceURL = "builders/_all/force"
+            data += make_force_build_form(forceURL, True)
+
         return data
 
 
@@ -254,6 +290,7 @@
      /builders/BUILDERNAME/builds/NUM/steps/STEPNAME/logs/LOGNAME: a StatusLog
      /builders/BUILDERNAME/builds/NUM/tests : summarize test results
      /builders/BUILDERNAME/builds/NUM/tests/TEST.NAME: results of one test
+     /builders/_all/{force,stop}: force a build/stop building on all builders.
      /changes : summarize all ChangeSources
      /changes/CHANGENUM: a page describing a single Change
      /schedulers/SCHEDULERNAME: a page describing a Scheduler, including

Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/builder.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- builder.py	21 Nov 2007 09:23:34 -0000	1.16
+++ builder.py	21 Nov 2007 09:24:18 -0000	1.17
@@ -11,7 +11,7 @@
 from buildbot.process.base import BuildRequest
 from buildbot.sourcestamp import SourceStamp
 
-from buildbot.status.web.build import BuildsResource
+from buildbot.status.web.build import BuildsResource, StatusResourceBuild
 
 # /builders/$builder
 class StatusResourceBuilder(HtmlResource, OneLineMixin):
@@ -204,6 +204,57 @@
         return HtmlResource.getChild(self, path, req)
 
 
+# /builders/_all
+class StatusResourceAllBuilders(HtmlResource, OneLineMixin):
+
+    def __init__(self, status, control):
+        HtmlResource.__init__(self)
+        self.status = status
+        self.control = control
+
+    def getChild(self, path, req):
+        if path == "force":
+            return self.force(req)
+        if path == "stop":
+            return self.stop(req)
+
+        return HtmlResource.getChild(self, path, req)
+
+    def force(self, req):
+        for bname in self.status.getBuilderNames():
+            builder_status = self.status.getBuilder(bname)
+            builder_control = None
+            c = self.getControl(req)
+            if c:
+                builder_control = c.getBuilder(bname)
+            build = StatusResourceBuilder(builder_status, builder_control)
+            build.force(req)
+        return Redirect("../../waterfall")
+
+    def stop(self, req):
+        for bname in self.status.getBuilderNames():
+            builder_status = self.status.getBuilder(bname)
+            builder_control = None
+            c = self.getControl(req)
+            if c:
+                builder_control = c.getBuilder(bname)
+            (state, current_builds) = builder_status.getState()
+            if state != "building":
+                continue
+            for b in current_builds:
+                build_status = builder_status.getBuild(b.number)
+                if not build_status:
+                    continue
+                if builder_control:
+                    build_control = builder_control.getBuild(b.number)
+                else:
+                    build_control = None
+                build = StatusResourceBuild(build_status, build_control,
+                                            builder_control)
+                build.stop(req)
+        return Redirect("../../waterfall")
+
+
 # /builders
 class BuildersResource(HtmlResource):
     title = "Builders"
@@ -235,6 +286,9 @@
             if c:
                 builder_control = c.getBuilder(path)
             return StatusResourceBuilder(builder_status, builder_control)
+        if path == "_all":
+            return StatusResourceAllBuilders(self.getStatus(req),
+                                             self.getControl(req))
 
         return HtmlResource.getChild(self, path, req)
 





More information about the Commits mailing list