[Buildbot-commits] buildbot/buildbot/status words.py,1.27,1.28

Brian Warner warner at users.sourceforge.net
Sun Nov 28 01:53:55 UTC 2004


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

Modified Files:
	words.py 
Log Message:
(IrcStatusBot.convertTime): utility method to express ETA time like "2m45s"
instead of "165 seconds"


Index: words.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/words.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- words.py	12 Oct 2004 17:49:30 -0000	1.27
+++ words.py	28 Nov 2004 01:53:52 -0000	1.28
@@ -123,6 +123,17 @@
         builders = [self.status.getBuilder(n) for n in names]
         return builders
 
+    def convertTime(self, seconds):
+        if seconds < 60:
+            return "%d seconds" % seconds
+        minutes = seconds / 60
+        seconds = seconds - 60*minutes
+        if minutes < 60:
+            return "%dm%02ds" % (minutes, seconds)
+        hours = minutes / 60
+        minutes = minutes - 60*hours
+        return "%dh%02dm%02ds" % (hours, minutes, seconds)
+
     def doSilly(self, user, reply, message):
         response = self.silly[message]
         if type(response) != type([]):
@@ -188,7 +199,7 @@
             % (which, build.getNumber())
         eta = build.getETA()
         if eta is not None:
-            r += " [%d seconds]" % eta
+            r += " [%s]" % self.convertTime(eta)
         r += ".."
         self.reply(reply, r)
     command_WATCH.usage = "watch <which> - announce the completion of an active build"
@@ -238,7 +249,7 @@
         eta = s.getETA()
         response = "build #%d forced" % s.getNumber()
         if eta is not None:
-            response = "build forced [ETA %d seconds]" % eta
+            response = "build forced [ETA %s]" % self.convertTime(eta)
         self.reply(reply, response)
         self.reply(reply, "I'll give a shout when the build finishes")
         d = s.waitUntilFinished()
@@ -257,14 +268,14 @@
                 str += ", last build %s secs ago: %s" % \
                        (int(util.now() - finished), " ".join(last.getText()))
         if state == "waiting":
-            str += " [next build in %d seconds]" % ETA
+            str += " [next build in %s]" % self.convertTime(ETA)
         if state == "building":
             build = b.getCurrentBuild()
             assert build
             step = build.getCurrentStep()
             str += " (%s)" % " ".join(step.getText())
             if ETA is not None:
-                str += " [ETA %d seconds]" % ETA
+                str += " [ETA %s]" % self.convertTime(ETA)
         self.reply(reply, str)
 
     def emit_last(self, reply, which):





More information about the Commits mailing list