Skip to content

Commit

Permalink
status.words.py: Make Contact a proper IStatusReceiver
Browse files Browse the repository at this point in the history
Since Contact is an IStatusReceiver, it (and its subclasses) should
declare that they implement IStatusReceiver. As well, make Contact
inherit from base.StatusReceiver so that the unimplemented
IStatusReceiver methods do not need to be stubbed out.

Add a note to developer.texinfo saying that this pattern should[*] be
followed for all IStatusReceivers.

[*] "should" instead of "must" as of 9c2bf24 (make notifications a bit
more resilient to missing methods, 2010-02-13) and c79f09b (check for
notification methods before calling them, 2010-02-15)
  • Loading branch information
jaysoffian committed Apr 8, 2010
1 parent b0dfe34 commit 673369b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
21 changes: 7 additions & 14 deletions buildbot/status/words.py
Expand Up @@ -13,6 +13,7 @@

from buildbot import interfaces, util
from buildbot import version
from buildbot.interfaces import IStatusReceiver
from buildbot.sourcestamp import SourceStamp
from buildbot.status import base
from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, EXCEPTION
Expand Down Expand Up @@ -57,7 +58,8 @@ def started(self, s):
d = s.waitUntilFinished()
d.addCallback(self.parent.watchedBuildFinished)

class Contact:
class Contact(base.StatusReceiver):
implements(IStatusReceiver)
"""I hold the state for a single user's interaction with the buildbot.
This base class provides all the basic behavior (the queries and
Expand All @@ -70,6 +72,7 @@ class Contact:
"""

def __init__(self, channel):
#StatusReceiver.__init__(self) doesn't exist
self.channel = channel
self.notify_events = {}
self.subscribed = 0
Expand Down Expand Up @@ -284,10 +287,6 @@ def requestSubmitted(self, brstatus):
log.msg('[Contact] BuildRequest for %s submitted to Builder %s' %
(brstatus.getSourceStamp(), brstatus.builderName))

def requestCancelled(self, brstatus):
# nothing happens with this notification right now
pass

def builderRemoved(self, builderName):
log.msg('[Contact] Builder %s removed' % (builderName))

Expand Down Expand Up @@ -348,15 +347,6 @@ def buildFinished(self, builderName, build, results):

self.send(r)

def changeAdded(self, change):
pass

def slaveConnected(self, slaveName):
pass

def slaveDisconnected(self, slaveName):
pass

def notify_for_finished(self, build):
results = build.getResults()

Expand Down Expand Up @@ -593,6 +583,8 @@ def handleAction(self, data, user):
reactor.callLater(timeout, self.act, response)

class IRCContact(Contact):
implements(IStatusReceiver)

# this is the IRC-specific subclass of Contact

def __init__(self, channel, dest):
Expand Down Expand Up @@ -860,6 +852,7 @@ def clientConnectionFailed(self, connector, reason):


class IRC(base.StatusReceiverMultiService):
implements(IStatusReceiver)
"""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."""
Expand Down
4 changes: 3 additions & 1 deletion docs/developer.texinfo
Expand Up @@ -58,7 +58,9 @@ notifications.

@item IStatusReceiver implementations

Objects from the 'status' configuration key are attached directly to the buildmaster.
Objects from the 'status' configuration key are attached directly to the
buildmaster. These classes should inherit from StatusReceiver or
StatusReceiverMultiService and include an 'implements(IStatusReceiver)' stanza.

@end itemize

Expand Down

0 comments on commit 673369b

Please sign in to comment.