[Buildbot-commits] buildbot/buildbot/changes base.py,NONE,1.1 freshcvs.py,1.19,1.20 changes.py,1.22,1.23 pb.py,1.7,1.8 p4poller.py,1.3,1.4 mail.py,1.17,1.18

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


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

Modified Files:
	freshcvs.py changes.py pb.py p4poller.py mail.py 
Added Files:
	base.py 
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
	reactor.


--- NEW FILE: base.py ---
#! /usr/bin/python

from twisted.application import service
from twisted.python import components

from buildbot.twcompat import implements
from buildbot.interfaces import IChangeSource
from buildbot import util

class ChangeSource(service.Service, util.ComparableMixin):
    if implements:
        implements(IChangeSource)
    else:
        __implements__ = IChangeSource, service.Service.__implements__

Index: changes.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/changes/changes.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- changes.py	6 May 2005 04:42:40 -0000	1.22
+++ changes.py	17 May 2005 10:14:09 -0000	1.23
@@ -15,6 +15,7 @@
 from twisted.web import html
 
 from buildbot import interfaces, util
+from buildbot.twcompat import implements, providedBy
 
 html_tmpl = """
 <p>Changed by: <b>%(who)s</b><br />
@@ -51,7 +52,11 @@
     chronologically increasing order. Out-of-order changes will probably
     cause the html.Waterfall display to be corrupted."""
 
-    __implements__ = interfaces.IStatusEvent,
+    if implements:
+        implements(interfaces.IStatusEvent)
+    else:
+        __implements__ = interfaces.IStatusEvent,
+
     links = []
     number = None
     revision = None # used to create a source-stamp
@@ -175,8 +180,8 @@
         self.nextNumber = 1
 
     def addSource(self, source):
-        assert components.implements(source, interfaces.IChangeSource)
-        assert components.implements(source, service.IService)
+        assert providedBy(source, interfaces.IChangeSource)
+        assert providedBy(source, service.IService)
         if self.debug:
             print "ChangeMaster.addSource", source
         source.setServiceParent(self)

Index: freshcvs.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/changes/freshcvs.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- freshcvs.py	23 Sep 2004 09:10:09 -0000	1.19
+++ freshcvs.py	17 May 2005 10:14:09 -0000	1.20
@@ -9,6 +9,7 @@
 
 import cvstoys.common # to make sure VersionedPatch gets registered
 
+from buildbot.twcompat import implements
 from buildbot.interfaces import IChangeSource
 from buildbot.pbutil import ReconnectingPBClientFactory
 from buildbot.changes.changes import Change
@@ -60,7 +61,10 @@
     does not, later versions might.
     """
 
-    __implements__ = IChangeSource, TCPClient.__implements__
+    if implements:
+        implements(IChangeSource)
+    else:
+        __implements__ = IChangeSource, TCPClient.__implements__
     compare_attrs = ["where", "prefix"]
 
     changemaster = None # filled in when we're added

Index: mail.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/changes/mail.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mail.py	6 May 2005 04:42:41 -0000	1.17
+++ mail.py	17 May 2005 10:14:09 -0000	1.18
@@ -7,9 +7,8 @@
 from rfc822 import Message
 
 from buildbot import util
-from buildbot.interfaces import IChangeSource
-from buildbot.changes.maildirtwisted import MaildirTwisted
-from buildbot.changes.changes import Change
+from buildbot.twcompat import implements
+from buildbot.changes import base, changes, maildirtwisted
 
 def parseFreshCVSMail(self, fd, prefix=None, sep="/"):
     """Parse mail sent by FreshCVS"""
@@ -77,7 +76,7 @@
     if not files:
         return None
     
-    change = Change(who, files, comments, isdir, when=when)
+    change = changes.Change(who, files, comments, isdir, when=when)
 
     return change
 
@@ -196,7 +195,7 @@
         comments += line
     comments = comments.rstrip() + "\n"
     
-    change = Change(who, files, comments, isdir, when=when, tag=tag)
+    change = changes.Change(who, files, comments, isdir, when=when, tag=tag)
 
     return change
 
@@ -287,20 +286,25 @@
     comments = comments.rstrip() + "\n"
 
     # return buildbot Change object
-    return Change(who, files, comments, when=timestamp)
+    return changes.Change(who, files, comments, when=timestamp)
 
 
-class MaildirSource(MaildirTwisted, util.ComparableMixin):
+class MaildirSource(maildirtwisted.MaildirTwisted, base.ChangeSource):
     """This source will watch a maildir that is subscribed to a FreshCVS
     change-announcement mailing list.
     """
+    # we need our own implements() here, at least for twisted-1.3, because
+    # the double-inheritance of Service shadows __implements__ from
+    # ChangeSource.
+    if not implements:
+        __implements__ = base.ChangeSource.__implements__
 
     compare_attrs = ["basedir", "newdir", "pollinterval", "parser"]
     parser = None
     name = None
 
     def __init__(self, maildir, prefix=None, sep="/"):
-        MaildirTwisted.__init__(self, maildir)
+        maildirtwisted.MaildirTwisted.__init__(self, maildir)
         self.prefix = prefix
         self.sep = sep
 
@@ -316,16 +320,13 @@
                   os.path.join(self.basedir, "cur", filename))
 
 class FCMaildirSource(MaildirSource):
-    __implements__ = (IChangeSource, MaildirSource.__implements__)
     parser = parseFreshCVSMail
     name = "FreshCVS"
 
 class SyncmailMaildirSource(MaildirSource):
-    __implements__ = (IChangeSource, MaildirSource.__implements__)
     parser = parseSyncmail
     name = "Syncmail"
 
 class BonsaiMaildirSource(MaildirSource):
-    __implements__ = (IChangeSource, MaildirSource.__implements__)
     parser = parseBonsaiMail
     name = "Bonsai"

Index: p4poller.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/changes/p4poller.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- p4poller.py	18 Apr 2005 00:26:57 -0000	1.3
+++ p4poller.py	17 May 2005 10:14:09 -0000	1.4
@@ -2,20 +2,17 @@
 
 # Many thanks to Dave Peticolas for contributing this module
 
-from twisted.application import service
 from twisted.internet import defer
 from twisted.internet.utils import getProcessOutput
 from twisted.internet.task import LoopingCall
 
 from buildbot import util
-from buildbot.interfaces import IChangeSource
-from buildbot.changes.changes import Change
+from buildbot.changes import base, changes
 
-class P4Source(service.Service, util.ComparableMixin):
+class P4Source(base.ChangeSource, util.ComparableMixin):
     """This source will poll a perforce repository for changes and submit
     them to the change master."""
 
-    __implements__ = IChangeSource, service.Service.__implements__
     compare_attrs = ["p4port", "p4user", "p4client", "p4base",
                      "p4bin", "pollinterval", "histmax"]
 
@@ -55,11 +52,11 @@
     def startService(self):
         self.loop = LoopingCall(self.checkp4)
         self.loop.start(self.pollinterval)
-        service.Service.startService(self)
+        base.ChangeSource.startService(self)
 
     def stopService(self):
         self.loop.stop()
-        return service.Service.stopService(self)
+        return base.ChangeSource.stopService(self)
 
     def describe(self):
         return "p4source %s:%s %s" % (self.p4port, self.p4client, self.p4base)
@@ -119,7 +116,8 @@
     def _handle_changes(self, result):
         for success, change in result:
             if not success: continue
-            c = Change(change['user'], change['files'], change['comments'],
-                       revision=change['num'])
+            c = changes.Change(change['user'], change['files'],
+                               change['comments'],
+                               revision=change['num'])
             self.parent.addChange(c)
             self.last_change = change['num']

Index: pb.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/changes/pb.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- pb.py	4 May 2005 02:09:38 -0000	1.7
+++ pb.py	17 May 2005 10:14:09 -0000	1.8
@@ -6,8 +6,7 @@
 from twisted.python import log
 
 from buildbot.pbutil import NewCredPerspective
-from buildbot.changes.changes import Change
-from buildbot.interfaces import IChangeSource
+from buildbot.changes import base, changes
 
 class ChangePerspective(NewCredPerspective):
 
@@ -40,14 +39,13 @@
             pathnames.append(path)
 
         if pathnames:
-            change = Change(changedict['who'],
-                            pathnames,
-                            changedict['comments'],
-                            revision=changedict.get('revision'))
+            change = changes.Change(changedict['who'],
+                                    pathnames,
+                                    changedict['comments'],
+                                    revision=changedict.get('revision'))
             self.changemaster.addChange(change)
 
-class PBChangeSource(service.Service):
-    __implements__ = IChangeSource, service.Service.__implements__
+class PBChangeSource(base.ChangeSource):
 
     def __init__(self, user="change", passwd="changepw", port=None,
                  prefix=None, sep="/"):
@@ -70,7 +68,7 @@
         return d
 
     def startService(self):
-        service.Service.startService(self)
+        base.ChangeSource.startService(self)
         # our parent is the ChangeMaster object
         # find the master's Dispatch object and register our username
         # TODO: the passwd should be registered here too
@@ -78,7 +76,7 @@
         master.dispatcher.register(self.user, self)
 
     def stopService(self):
-        service.Service.stopService(self)
+        base.ChangeSource.stopService(self)
         # unregister our username
         master = self.parent.parent
         master.dispatcher.unregister(self.user)





More information about the Commits mailing list