[Buildbot-commits] buildbot/buildbot/status html.py,1.65,1.66 builder.py,1.64,1.65

Brian Warner warner at users.sourceforge.net
Wed Aug 31 01:51:45 UTC 2005


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

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

add pending/upcoming builds to the HTML "Current Activity" row

	* buildbot/status/html.py: add pending/upcoming builds to CurrentBox
	* buildbot/interfaces.py (IScheduler.getPendingBuildTimes): new method
	(IStatus.getSchedulers): new method
	* buildbot/status/builder.py (BuilderStatus): track pendingBuilds
	(Status.getSchedulers): implement
	* buildbot/process/builder.py (Builder): maintain
	BuilderStatus.pendingBuilds
	* buildbot/scheduler.py (Scheduler.getPendingBuildTimes): new method
	(TryBase.addChange): Try schedulers should ignore Changes

--This line, and those below, will be ignored--
Files to commit:
   <can't compute list>

This list might be incomplete or outdated if editing the log
message was not invoked from an up-to-date changes buffer!


Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/builder.py,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- builder.py	17 Aug 2005 02:15:37 -0000	1.64
+++ builder.py	31 Aug 2005 01:51:42 -0000	1.65
@@ -1289,6 +1289,7 @@
         self.lastBuildStatus = None
         #self.currentBig = None
         #self.currentSmall = None
+        self.pendingBuilds = []
         self.nextBuild = None
         self.watchers = []
         self.buildCache = [] # TODO: age builds out of the cache
@@ -1303,6 +1304,7 @@
             self.currentBuild.saveYourself()
             # TODO: push a 'hey, build was interrupted' event
             del d['currentBuild']
+        del d['pendingBuilds']
         del d['currentBigState']
         del d['basedir']
         del d['status']
@@ -1311,6 +1313,7 @@
     def __setstate__(self, d):
         self.__dict__ = d
         self.buildCache = []
+        self.pendingBuilds = []
         self.watchers = []
         # self.basedir must be filled in by our parent
         # self.status must be filled in by our parent
@@ -1381,6 +1384,9 @@
     def getSlave(self):
         return self.status.getSlave(self.slavename)
 
+    def getPendingBuilds(self):
+        return self.pendingBuilds
+
     def getCurrentBuild(self):
         return self.currentBuild
 
@@ -1499,6 +1505,11 @@
         s.waitUntilFinished().addCallback(self._buildFinished)
         return s
 
+    def addBuildRequest(self, brstatus):
+        self.pendingBuilds.append(brstatus)
+    def removeBuildRequest(self, brstatus):
+        self.pendingBuilds.remove(brstatus)
+
     # buildStarted is called by our child BuildStatus instances
     def buildStarted(self, s):
         """Now the BuildStatus object is ready to go (it knows all of its
@@ -1673,6 +1684,9 @@
     def getBuildbotURL(self):
         return self.botmaster.parent.buildbotURL
 
+    def getSchedulers(self):
+        return self.botmaster.parent.schedulers
+
     def getBuilderNames(self, categories=None):
         if categories == None:
             return self.botmaster.builderNames[:] # don't let them break it

Index: html.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/html.py,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- html.py	19 Jul 2005 23:12:01 -0000	1.65
+++ html.py	31 Aug 2005 01:51:42 -0000	1.66
@@ -674,21 +674,49 @@
         __implements__ = ICurrentBox,
 
     def formatETA(self, eta):
-        return time.strftime("%H:%M:%S", time.localtime(util.now()+eta))
+        if eta is None:
+            return []
+        if eta < 0:
+            return ["Soon"]
+        abstime = time.strftime("%H:%M:%S", time.localtime(util.now()+eta))
+        return ["ETA in", "%d secs" % eta, "at %s" % abstime]
 
-    def getBox(self):
+    def getBox(self, status):
+        # getState() returns offline, idle, or building
         state, build = self.original.getState()
         color = "white"
         if state == "building":
             color = "yellow"
-        text = [state]
-        if state == "offline":
+            text = ["building"] + self.formatETA(build.getETA())
+        elif state == "offline":
             color = "red"
-        if state == "building":
-            # TODO: ETA calculation
-            pass
+            text = ["offline"]
+        elif state == "idle":
+            text = ["idle"]
+        else:
+            # just in case I add a state and forget to update this
+            text = [state]
+
+        # TODO: for now, this pending/upcoming stuff is in the "current
+        # activity" box, but really it should go into a "next activity" row
+        # instead. The only times it should show up in "current activity" is
+        # when the builder is otherwise idle.
 
+        # are any builds pending? (waiting for a slave to be free)
+        pbs = self.original.getPendingBuilds()
+        if pbs:
+            text.append("%d pending" % len(pbs))
+        # how about upcoming ones?
+        upcoming = []
+        builderName = self.original.getName()
+        for s in status.getSchedulers():
+            if builderName in s.listBuilderNames():
+                upcoming.extend(s.getPendingBuildTimes())
+        for t in upcoming:
+            text.extend(["next at", 
+                         time.strftime("%H:%M:%S", time.localtime(t))])
         return Box(text, color=color, class_="Activity " + state)
+
 components.registerAdapter(CurrentBox, builder.BuilderStatus, ICurrentBox)
 
 class ChangeBox(components.Adapter):
@@ -915,7 +943,7 @@
         data += td("current activity", align="right", colspan=2,
                    class_="Activity")
         for b in builders:
-            box = ICurrentBox(b).getBox()
+            box = ICurrentBox(b).getBox(self.status)
             data += box.td(align="center")
         data += " </tr>\n"
         





More information about the Commits mailing list