[Buildbot-commits] buildbot/buildbot/status builder.py,1.68,1.69

Brian Warner warner at users.sourceforge.net
Sun Oct 16 06:25:37 UTC 2005


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

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

add getURLForThing status method

	* buildbot/status/builder.py (Status.getURLForThing): add method
	to provide a URL for arbitrary IStatusFoo objects. The idea is to
	use this in email/IRC status clients to make them more useful, by
	providing the end user with hints on where to learn more about the
	object being reported on.
	* buildbot/test/test_web.py (GetURL): tests for it


Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/builder.py,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- builder.py	14 Oct 2005 19:42:40 -0000	1.68
+++ builder.py	16 Oct 2005 06:25:34 -0000	1.69
@@ -15,7 +15,7 @@
 
 # sibling imports
 from buildbot import interfaces, util, sourcestamp
-from buildbot.twcompat import implements
+from buildbot.twcompat import implements, providedBy
 
 SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION = range(5)
 Results = ["success", "warnings", "failure", "skipped", "exception"]
@@ -1708,6 +1708,63 @@
     def getBuildbotURL(self):
         return self.botmaster.parent.buildbotURL
 
+    def getURLForThing(self, thing):
+        prefix = self.getBuildbotURL()
+        if not prefix:
+            return None
+        if providedBy(thing, interfaces.IStatus):
+            return prefix
+        if providedBy(thing, interfaces.ISchedulerStatus):
+            pass
+        if providedBy(thing, interfaces.IBuilderStatus):
+            builder = thing
+            return prefix + builder.getName()
+        if providedBy(thing, interfaces.IBuildStatus):
+            build = thing
+            builder = build.getBuilder()
+            return "%s%s/builds/%d" % (prefix,
+                                       builder.getName(),
+                                       build.getNumber())
+        if providedBy(thing, interfaces.IBuildStepStatus):
+            step = thing
+            build = step.getBuild()
+            builder = build.getBuilder()
+            return "%s%s/builds/%d/%s" % (prefix,
+                                          builder.getName(),
+                                          build.getNumber(),
+                                          step.getName())
+        # IBuildSetStatus
+        # IBuildRequestStatus
+        # ISlaveStatus
+
+        # IStatusEvent
+        if providedBy(thing, interfaces.IStatusEvent):
+            from buildbot.changes import changes
+            # TODO: this is goofy, create IChange or something
+            if isinstance(thing, changes.Change):
+                change = thing
+                return "%schanges/%d" % (prefix, change.number)
+
+        if providedBy(thing, interfaces.IStatusLog):
+            log = thing
+            step = log.getStep()
+            build = step.getBuild()
+            builder = build.getBuilder()
+
+            logs = step.getLogs()
+            for i in range(len(logs)):
+                if log is logs[i]:
+                    lognum = i
+                    break
+            else:
+                return None
+            return "%s%s/builds/%d/%s/%d" % (prefix,
+                                             builder.getName(),
+                                             build.getNumber(),
+                                             step.getName(),
+                                             lognum)
+
+
     def getSchedulers(self):
         return self.botmaster.parent.schedulers
 





More information about the Commits mailing list