[Buildbot-commits] buildbot/buildbot twcompat.py,NONE,1.1 master.py,1.71,1.72

Brian Warner warner at users.sourceforge.net
Tue May 17 10:14:12 UTC 2005

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

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

fix deprecation warnings in test suite

	* everything: fixed all deprecation warnings when running against
	Twisted-2.0 . (at least all the ones in buildbot code, there are a
	few that come from Twisted itself). This involved putting most of
	the Twisted-version specific code in the new buildbot.twcompat
	module, and creating some abstract base classes in
	buildbot.changes.base and buildbot.status.base (which might be
	useful anyway). __implements__ is a nuisance and requires an ugly
	'if' clause everywhere.

	* buildbot/test/test_status.py (Mail.testMail): add a 0.1 second
	delay before finishing the test: it seems that smtp.sendmail
	doesn't hang up on the server, so we must wait a moment so it can
	hang up on us. This removes the trial warning about an unclean

Index: master.py
RCS file: /cvsroot/buildbot/buildbot/buildbot/master.py,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- master.py	6 May 2005 05:01:11 -0000	1.71
+++ master.py	17 May 2005 10:14:10 -0000	1.72
@@ -21,6 +21,7 @@
 # sibling imports
 from buildbot import util
+from buildbot.twcompat import implements
 from buildbot.util import now
 from buildbot.pbutil import NewCredPerspective
 from buildbot.process.interlock import Interlock
@@ -513,7 +514,10 @@
         print "debug", msg
 class Dispatcher(styles.Versioned):
-    __implements__ = portal.IRealm
+    if implements:
+        implements(portal.IRealm)
+    else:
+        __implements__ = portal.IRealm,
     persistenceVersion = 2
     def __init__(self):
@@ -1000,7 +1004,10 @@
 class Control:
-    __implements__ = interfaces.IControl,
+    if implements:
+        implements(interfaces.IControl)
+    else:
+        __implements__ = interfaces.IControl,
     def __init__(self, master):
         self.master = master

--- NEW FILE: twcompat.py ---

from twisted.python import components

utilities to be compatible with both Twisted-1.3 and 2.0

implements. Use this like:
    from buildbot.tcompat import implements
    class Foo:
        if implements:
            __implements__ = IFoo,
    from buildbot.tcompat import Interface
    class IFoo(Interface)

    from buildbot.tcompat import providedBy
    assert providedBy(obj, IFoo)

# does our Twisted use zope.interface?
if hasattr(components, "interface"):
    # yes
    from zope.interface import implements
    from zope.interface import Interface
    def providedBy(obj, iface):
        return iface.providedBy(obj)
    # nope
    implements = None
    from twisted.python.components import Interface
    providedBy = components.implements

More information about the Commits mailing list