[Buildbot-commits] buildbot/buildbot/status base.py,NONE,1.1 client.py,1.17,1.18 html.py,1.63,1.64 words.py,1.35,1.36 builder.py,1.57,1.58 mail.py,1.15,1.16
Brian Warner
warner at users.sourceforge.net
Tue May 17 10:14:11 UTC 2005
Update of /cvsroot/buildbot/buildbot/buildbot/status
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9810/buildbot/status
Modified Files:
client.py html.py words.py builder.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
try:
from zope.interface import implements
except ImportError:
implements = None
if not hasattr(components, "interface"):
implements = None # nope
from buildbot.interfaces import IStatusReceiver
from buildbot import util, pbutil
class StatusReceiver:
if implements:
implements(IStatusReceiver)
else:
__implements__ = IStatusReceiver,
def builderAdded(self, builderName, builder):
pass
def builderChangedState(self, builderName, state, eta=None):
pass
def buildStarted(self, builderName, build):
pass
def buildETAUpdate(self, build, ETA):
pass
def stepStarted(self, build, step):
pass
def stepETAUpdate(self, build, step, ETA, expectations):
pass
def logStarted(self, build, step, log):
pass
def logChunk(self, build, step, log, channel, text):
pass
def logFinished(self, build, step, log):
pass
def stepFinished(self, build, step, results):
pass
def buildFinished(self, builderName, build, results):
pass
def builderRemoved(self, builderName):
pass
class StatusReceiverMultiService(service.MultiService, util.ComparableMixin):
if implements:
implements(IStatusReceiver)
else:
__implements__ = IStatusReceiver, service.MultiService.__implements__
class StatusReceiverPerspective(StatusReceiver, pbutil.NewCredPerspective):
if implements:
implements(IStatusReceiver)
else:
__implements__ = (IStatusReceiver,
pbutil.NewCredPerspective.__implements__)
Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/builder.py,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- builder.py 16 May 2005 00:31:53 -0000 1.57
+++ builder.py 17 May 2005 10:14:09 -0000 1.58
@@ -2,7 +2,7 @@
from __future__ import generators
-from twisted.python import log, components
+from twisted.python import log
from twisted.persisted import styles
from twisted.internet import reactor, defer
from twisted.protocols import basic
@@ -15,6 +15,7 @@
# sibling imports
from buildbot import interfaces, util
+from buildbot.twcompat import implements
SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION = range(5)
Results = ["success", "warnings", "failure", "skipped", "exception"]
@@ -194,7 +195,11 @@
so users who go from 0.6.5 back to 0.6.4 don't have to lose their
logs."""
- __implements__ = interfaces.IStatusLog,
+ if implements:
+ implements(interfaces.IStatusLog)
+ else:
+ __implements__ = interfaces.IStatusLog,
+
finished = False
length = 0
progress = None
@@ -431,7 +436,11 @@
class HTMLLogFile:
- __implements__ = interfaces.IStatusLog,
+ if implements:
+ implements(interfaces.IStatusLog)
+ else:
+ __implements__ = interfaces.IStatusLog,
+
filename = None
def __init__(self, parent, name, logfilename, html):
@@ -474,7 +483,10 @@
class Event:
- __implements__ = interfaces.IStatusEvent,
+ if implements:
+ implements(interfaces.IStatusEvent)
+ else:
+ __implements__ = interfaces.IStatusEvent,
started = None
finished = None
@@ -495,7 +507,10 @@
self.finished = util.now()
class TestResult:
- __implements__ = interfaces.ITestResult,
+ if implements:
+ implements(interfaces.ITestResult)
+ else:
+ __implements__ = interfaces.ITestResult,
def __init__(self, name, results, text, logs):
assert type(name) is tuple
@@ -538,7 +553,10 @@
"""
# note that these are created when the Build is set up, before each
# corresponding BuildStep has started.
- __implements__ = interfaces.IBuildStepStatus, interfaces.IStatusEvent
+ if implements:
+ implements(interfaces.IBuildStepStatus, interfaces.IStatusEvent)
+ else:
+ __implements__ = interfaces.IBuildStepStatus, interfaces.IStatusEvent
started = None
finished = None
@@ -753,7 +771,10 @@
class BuildStatus:
- __implements__ = interfaces.IBuildStatus, interfaces.IStatusEvent
+ if implements:
+ implements(interfaces.IBuildStatus, interfaces.IStatusEvent)
+ else:
+ __implements__ = interfaces.IBuildStatus, interfaces.IStatusEvent
sourceStamp = None
reason = None
@@ -1115,7 +1136,10 @@
used to filter on in status clients
"""
- __implements__ = interfaces.IBuilderStatus,
+ if implements:
+ implements(interfaces.IBuilderStatus)
+ else:
+ __implements__ = interfaces.IBuilderStatus,
# these limit the amount of memory we consume, as well as the size of the
# main Builder pickle. The Build and LogFile pickles on disk must be
@@ -1580,7 +1604,10 @@
self.subscribers.remove(client)
class SlaveStatus:
- __implements__ = interfaces.ISlaveStatus,
+ if implements:
+ implements(interfaces.ISlaveStatus)
+ else:
+ __implements__ = interfaces.ISlaveStatus,
admin = None
host = None
@@ -1602,7 +1629,10 @@
"""
I represent the status of the buildmaster.
"""
- __implements__ = interfaces.IStatus,
+ if implements:
+ implements(interfaces.IStatus)
+ else:
+ __implements__ = interfaces.IStatus,
def __init__(self, botmaster, basedir):
"""
Index: client.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/client.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- client.py 26 Apr 2005 09:08:30 -0000 1.17
+++ client.py 17 May 2005 10:14:09 -0000 1.18
@@ -8,11 +8,11 @@
from twisted.cred import portal, checkers
from buildbot import util, interfaces
-from buildbot.pbutil import NewCredPerspective
-from buildbot.status import builder
+from buildbot.twcompat import Interface, implements
+from buildbot.status import builder, base
from buildbot.changes import changes
-class IRemote(components.Interface):
+class IRemote(Interface):
pass
def makeRemote(obj):
@@ -218,9 +218,7 @@
components.registerAdapter(RemoteChange, changes.Change, IRemote)
-class StatusClientPerspective(NewCredPerspective):
- __implements__ = (NewCredPerspective.__implements__,
- interfaces.IStatusReceiver)
+class StatusClientPerspective(base.StatusReceiverPerspective):
subscribed = None
client = None
@@ -398,13 +396,15 @@
channel, text)
-class PBListener(service.MultiService, util.ComparableMixin):
+class PBListener(base.StatusReceiverMultiService):
"""I am a listener for PB-based status clients."""
compare_attrs = ["port", "cred"]
- __implements__ = (interfaces.IStatusReceiver,
- portal.IRealm,
- service.MultiService.__implements__)
+ if implements:
+ implements(portal.IRealm)
+ else:
+ __implements__ = (portal.IRealm,
+ base.StatusReceiverMultiService.__implements__)
def __init__(self, port, user="statusClient", passwd="clientpw"):
service.MultiService.__init__(self)
Index: html.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/html.py,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- html.py 15 May 2005 23:43:57 -0000 1.63
+++ html.py 17 May 2005 10:14:09 -0000 1.64
@@ -11,30 +11,32 @@
from twisted.web import static, html, server, distrib
from twisted.web.error import NoResource
from twisted.web.util import Redirect, DeferredResource
-from twisted.application import service, internet
+from twisted.application import internet
from twisted.spread import pb
+from buildbot.twcompat import implements, Interface
+
import string, types, time, os.path
from buildbot import interfaces, util
from buildbot import version
-from buildbot.status import builder
+from buildbot.status import builder, base
from buildbot.changes import changes
-class ITopBox(components.Interface):
+class ITopBox(Interface):
"""I represent a box in the top row of the waterfall display: the one
which shows the status of the last build for each builder."""
pass
-class ICurrentBox(components.Interface):
+class ICurrentBox(Interface):
"""I represent the 'current activity' box, just above the builder name."""
pass
-class IBox(components.Interface):
+class IBox(Interface):
"""I represent a box in the waterfall display."""
pass
-class IHTMLLog(components.Interface):
+class IHTMLLog(Interface):
pass
ROW_TEMPLATE = '''
@@ -535,7 +537,11 @@
"""
class ChunkConsumer:
- __implements__ = interfaces.IStatusLogConsumer,
+ if implements:
+ implements(interfaces.IStatusLogConsumer)
+ else:
+ __implements__ = interfaces.IStatusLogConsumer,
+
def __init__(self, original, textlog):
self.original = original
self.textlog = textlog
@@ -556,7 +562,11 @@
class TextLog(Resource):
# a new instance of this Resource is created for each client who views
# it, so we can afford to track the request in the Resource.
- __implements__ = IHTMLLog,
+ if implements:
+ implements(IHTMLLog)
+ else:
+ __implements__ = IHTMLLog,
+
asText = False
subscribed = False
@@ -639,7 +649,10 @@
class HTMLLog(Resource):
- __implements__ = IHTMLLog,
+ if implements:
+ implements(IHTMLLog)
+ else:
+ __implements__ = IHTMLLog,
def __init__(self, original):
@@ -655,7 +668,10 @@
class CurrentBox(components.Adapter):
# this provides the "current activity" box, just above the builder name
- __implements__ = ICurrentBox,
+ if implements:
+ implements(ICurrentBox)
+ else:
+ __implements__ = ICurrentBox,
def formatETA(self, eta):
return time.strftime("%H:%M:%S", time.localtime(util.now()+eta))
@@ -684,7 +700,11 @@
components.registerAdapter(CurrentBox, builder.BuilderStatus, ICurrentBox)
class ChangeBox(components.Adapter):
- __implements__ = IBox,
+ if implements:
+ implements(IBox)
+ else:
+ __implements__ = IBox,
+
def getBox(self):
url = "changes/%d" % self.original.number
text = '<a href="%s">%s</a>' % (url, html.escape(self.original.who))
@@ -693,7 +713,10 @@
class BuildBox(components.Adapter):
# this provides the yellow "starting line" box for each build
- __implements__ = IBox,
+ if implements:
+ implements(IBox)
+ else:
+ __implements__ = IBox,
def getBox(self):
b = self.original
@@ -713,7 +736,11 @@
components.registerAdapter(BuildBox, builder.BuildStatus, IBox)
class StepBox(components.Adapter):
- __implements__ = IBox,
+ if implements:
+ implements(IBox)
+ else:
+ __implements__ = IBox,
+
def getBox(self):
b = self.original.getBuild()
urlbase = "%s/builds/%d/%s" % (b.getBuilder().getName(),
@@ -738,7 +765,11 @@
components.registerAdapter(StepBox, builder.BuildStepStatus, IBox)
class EventBox(components.Adapter):
- __implements__ = IBox,
+ if implements:
+ implements(IBox)
+ else:
+ __implements__ = IBox,
+
def getBox(self):
text = self.original.getText()
color = self.original.getColor()
@@ -752,7 +783,11 @@
class BuildTopBox(components.Adapter):
# this provides a per-builder box at the very top of the display,
# showing the results of the most recent build
- __implements__ = IBox,
+ if implements:
+ implements(IBox)
+ else:
+ __implements__ = IBox,
+
def getBox(self):
assert interfaces.IBuilderStatus(self.original)
b = self.original.getLastFinishedBuild()
@@ -775,7 +810,11 @@
self.finished = finish
class SpacerBox(components.Adapter):
- __implements__ = IBox,
+ if implements:
+ implements(IBox)
+ else:
+ __implements__ = IBox,
+
def getBox(self):
#b = Box(["spacer"], "white")
b = Box([])
@@ -1354,10 +1393,11 @@
# the icon is sibpath(__file__, "../buildbot.png") . This is for portability.
up = os.path.dirname
-buildbot_icon = os.path.abspath(os.path.join(up(up(__file__)), "buildbot.png"))
+buildbot_icon = os.path.abspath(os.path.join(up(up(__file__)),
+ "buildbot.png"))
buildbot_css = os.path.abspath(os.path.join(up(__file__), "classic.css"))
-class Waterfall(service.MultiService, util.ComparableMixin):
+class Waterfall(base.StatusReceiverMultiService):
"""I implement the primary web-page status interface, called a 'Waterfall
Display' because builds and steps are presented in a grid of boxes which
move downwards over time. The top edge is always the present. Each column
@@ -1395,8 +1435,7 @@
L{buildbot.master.BuildMaster} instance, through which
the status-reporting object is acquired.
"""
- __implements__ = (interfaces.IStatusReceiver,
- service.MultiService.__implements__)
+
compare_attrs = ["http_port", "distrib_port", "allowForce",
"categories", "css"]
@@ -1439,7 +1478,7 @@
a favicon at all.
"""
- service.MultiService.__init__(self)
+ base.StatusReceiverMultiService.__init__(self)
assert allowForce in (True, False) # TODO: implement others
self.http_port = http_port
self.distrib_port = distrib_port
@@ -1460,7 +1499,7 @@
"""
@type parent: L{buildbot.master.BuildMaster}
"""
- service.MultiService.setServiceParent(self, parent)
+ base.StatusReceiverMultiService.setServiceParent(self, parent)
self.setup()
def setup(self):
Index: mail.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/mail.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- mail.py 24 Apr 2005 21:30:25 -0000 1.15
+++ mail.py 17 May 2005 10:14:09 -0000 1.16
@@ -13,15 +13,23 @@
from twisted.internet import defer
from twisted.application import service
-from twisted.protocols.smtp import sendmail
-from twisted.python import components, log
+try:
+ from twisted.mail.smtp import sendmail # Twisted-2.0
+except ImportError:
+ from twisted.protocols.smtp import sendmail # Twisted-1.3
+from twisted.python import log
from buildbot import interfaces, util
+from buildbot.twcompat import implements, providedBy
+from buildbot.status import base
from buildbot.status.builder import FAILURE, SUCCESS, WARNINGS
class Domain(util.ComparableMixin):
- __implements__ = interfaces.IEmailLookup
+ if implements:
+ implements(interfaces.IEmailLookup)
+ else:
+ __implements__ = interfaces.IEmailLookup
compare_attrs = ["domain"]
def __init__(self, domain):
@@ -32,7 +40,7 @@
return name + "@" + self.domain
-class MailNotifier(service.Service, util.ComparableMixin):
+class MailNotifier(base.StatusReceiverMultiService):
"""This is a status notifier which sends email to a list of recipients
upon the completion of each build. It can be configured to only send out
mail for certain builds, and only send messages when the build fails, or
@@ -51,9 +59,11 @@
MailNotifiers.
"""
- __implements__ = (interfaces.IStatusReceiver,
- interfaces.IEmailSender,
- service.Service.__implements__)
+ if implements:
+ implements(interfaces.IEmailSender)
+ else:
+ __implements__ = (interfaces.IEmailSender,
+ base.StatusReceiverMultiService.__implements__)
compare_attrs = ["extraRecipients", "lookup", "fromaddr", "mode",
"categories", "builders", "addLogs", "relayhost",
@@ -144,7 +154,7 @@
if lookup is not None:
if type(lookup) is str:
lookup = Domain(lookup)
- assert components.implements(lookup, interfaces.IEmailLookup)
+ assert providedBy(lookup, interfaces.IEmailLookup)
self.lookup = lookup
self.watched = []
self.status = None
@@ -158,7 +168,7 @@
"""
@type parent: L{buildbot.master.BuildMaster}
"""
- service.Service.setServiceParent(self, parent)
+ base.StatusReceiverMultiService.setServiceParent(self, parent)
self.setup()
def setup(self):
@@ -169,7 +179,7 @@
self.status.unsubscribe(self)
for w in self.watched:
w.unsubscribe(self)
- return service.Service.disownServiceParent(self)
+ return base.StatusReceiverMultiService.disownServiceParent(self)
def builderAdded(self, name, builder):
# only subscribe to builders we are interested in
Index: words.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/words.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- words.py 26 Apr 2005 06:35:36 -0000 1.35
+++ words.py 17 May 2005 10:14:09 -0000 1.36
@@ -6,12 +6,18 @@
import traceback, StringIO, re
from twisted.internet import protocol, reactor
-from twisted.protocols import irc
+try:
+ # Twisted-2.0
+ from twisted.words.protocols import irc
+except ImportError:
+ # Twisted-1.3
+ from twisted.protocols import irc
from twisted.python import log, failure
-from twisted.application import service, internet
+from twisted.application import internet
from buildbot import interfaces, util
from buildbot import version
+from buildbot.status import base
from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE
class UsageError(ValueError):
@@ -487,19 +493,17 @@
ThrottledClientFactory.clientConnectionFailed(self, connector, reason)
-class IRC(service.MultiService, util.ComparableMixin):
+class IRC(base.StatusReceiverMultiService):
"""I am an IRC bot which can be queried for status information. I
connect to a single IRC server and am known by a single nickname on that
server, however I can join multiple channels."""
compare_attrs = ["host", "port", "nick", "channels", "allowForce",
"categories"]
- __implements__ = (interfaces.IStatusReceiver,
- service.MultiService.__implements__)
def __init__(self, host, nick, channels, port=6667, allowForce=True,
categories=None):
- service.MultiService.__init__(self)
+ base.StatusReceiverMultiService.__init__(self)
assert allowForce in (True, False) # TODO: implement others
@@ -518,7 +522,7 @@
c.setServiceParent(self)
def setServiceParent(self, parent):
- service.MultiService.setServiceParent(self, parent)
+ base.StatusReceiverMultiService.setServiceParent(self, parent)
self.f.status = parent.getStatus()
if self.allowForce:
self.f.control = interfaces.IControl(parent)
@@ -526,7 +530,7 @@
def stopService(self):
# make sure the factory will stop reconnecting
self.f.shutdown()
- return service.MultiService.stopService(self)
+ return base.StatusReceiverMultiService.stopService(self)
def main():
More information about the Commits
mailing list