[Buildbot-devel] Subclassing MailNotifier

Brian Warner warner-buildbot at lothar.com
Wed Aug 23 08:11:52 UTC 2006


> I am working on subclassing MailNotifier to sent tinderbox formatted
> e-mails. I've hit a road block though. Sometime after the a callback is
> added in buildMessage(), stepStarted() is attempt to be called from a
> BuildStatus object. Here is the traceback from the logs:

It sounds like you've created a TinderboxMailNotifier.buildStarted method,
and you're starting by copying the code from MailNotifier.buildFinished . You
probably want to be using buildFinished() and not buildStarted(). Or, if you
use buildStarted(), don't return anything from it.

The difference between buildStarted and buildFinished is that buildStarted
treats the return value differently. To make it easier for status plugins to
subscribe to events for the build just starting and make sure they don't miss
anything, you can return an observer from the method and it will be
automatically subscribed to hear about each step of the new build. See
buildbot.interfaces.IStatusReceiver.buildStarted for an explanation of the
return convention for this method.

The buildFinished() method you're using as a sample is unusual in that it
returns a Deferred. This is purely for the convenience of the unit tests and
is not used by buildbot itself. It just so happens that the status code which
invokes buildStarted() *does* pay attention to the value it returns, and a
Deferred is not a suitable return value.

The reason I think that you might want to be using buildFinished()
exclusively is that, as I understand it, the Tinderbox status-by-mail scheme
only sends out its one big machine-readable status email at the end of the
build. If it were sending multiple messages during the build, then yeah,
you'd want to do something at buildStarted() and something else at
buildFinished(). But I suspect you could just send out the one big message at
buildFinished() and be done with it. In this case, I think it might be
sufficient to override buildMessage() to construct the special
Tinderbox-formatted message, then copy the code at the end of
MailNotifier.buildMessage to extract the recipient list and invoke
sendMessage().

>           File
> "/usr/lib/python2.4/site-packages/buildbot/status/builder.py", line
> 1152, in stepStarted
>             receiver = w.stepStarted(self, step)
>         exceptions.AttributeError: Deferred instance has no attribute
> 'stepStarted'

This is the hint that something has gone wrong: that call to w.stepStarted()
is trying to invoke a method on an observer that was returned earlier. If an
observer's buildStarted() method returns an object, that object will be added
to the list of observers that care about Steps starting and finishing. This
w.stepStarted invocation is how that second observer is being notified. In
this case, I think your buildFinished() code returned a Deferred, which was
dutifully added to the list of observers with an interest in steps, when in
fact a Deferred has no idea what to do with a method call like stepStarted().


Let me know if that helps..
 -Brian




More information about the devel mailing list