[Buildbot-commits] buildbot/buildbot/status client.py,1.16,1.17

Brian Warner warner at users.sourceforge.net
Tue Apr 26 09:08:32 UTC 2005


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

Modified Files:
	client.py 
Log Message:
* buildbot/status/client.py (makeRemote): new approach to making
IRemote(None) be None, which works under Twisted-2.0
* buildbot/test/test_status.py (Client.testAdaptation): test it


Index: client.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/client.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- client.py	24 Apr 2005 21:30:25 -0000	1.16
+++ client.py	26 Apr 2005 09:08:30 -0000	1.17
@@ -15,9 +15,12 @@
 class IRemote(components.Interface):
     pass
 
-# make sure that IRemote(None) is None
-components.registerAdapter(lambda n: None,
-                           type(None), IRemote)
+def makeRemote(obj):
+    # we want IRemote(None) to be None, but you can't really do that with
+    # adapters, so we fake it
+    if obj is None:
+        return None
+    return IRemote(obj)
 
 class RemoteBuilder(pb.Referenceable):
     def __init__(self, builder):
@@ -28,22 +31,19 @@
 
     def remote_getState(self):
         state, ETA, build = self.b.getState()
-        return (state, ETA, IRemote(build))
+        return (state, ETA, makeRemote(build))
 
     def remote_getSlave(self):
         return IRemote(self.b.getSlave())
 
-    def remote_getCurrentBuild(self):
-        return IRemote(self.b.getCurrentBuild())
-
     def remote_getLastFinishedBuild(self):
-        return IRemote(self.b.getLastFinishedBuild())
+        return makeRemote(self.b.getLastFinishedBuild())
 
     def remote_getCurrentBuild(self):
-        return IRemote(self.b.getCurrentBuild())
+        return makeRemote(self.b.getCurrentBuild())
 
     def remote_getBuild(self, number):
-        return IRemote(self.b.getBuild(number))
+        return makeRemote(self.b.getBuild(number))
 
     def remote_getEvent(self, number):
         return IRemote(self.b.getEvent(number))
@@ -88,7 +88,7 @@
         return self.b.getETA()
 
     def remote_getCurrentStep(self):
-        return IRemote(self.b.getCurrentStep())
+        return makeRemote(self.b.getCurrentStep())
 
     def remote_getText(self):
         return self.b.getText()





More information about the Commits mailing list