我组织中的许多人具有与perforce名称不同的电子邮件名称,因此我需要创建一个IEmailLookup派生,该派生重写getAddress来进行恶意投标:

(来自我的master.cfg)

class MyIEmailLookup:
    from buildbot import interfaces
    __implements__ = interfaces.IEmailLookup

    def getAddresses(user):
        address_dict = {"user1", "user_one@our_domain.com"}
        try:
            address = address_dict[user]
        except KeyError:
            address = user + "@our_domain.com"
        return address

maillookup = MyIEmailLookup()

from buildbot.status import mail

c['status'].append(mail.MailNotifier(....
                                     ....
                                     lookup=maillookup
                                    ))


我尝试了任何数量的排列,但都得到了:

Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/buildbot-0.8.3p1-py2.6.egg/buildbot/scripts/runner.py", line 1071, in doCheckConfig
    ConfigLoader(configFileName=configFileName)
  File "/Library/Python/2.6/site-packages/buildbot-0.8.3p1-py2.6.egg/buildbot/scripts/checkconfig.py", line 46, in __init__
    self.loadConfig(configFile, check_synchronously_only=True)
  File "/Library/Python/2.6/site-packages/buildbot-0.8.3p1-py2.6.egg/buildbot/master.py", line 727, in loadConfig
    exec f in localDict
  File "/Users/playbuilder/buildbot/master.cfg", line 207, in <module>
    lookup=maillookup
  File "/Library/Python/2.6/site-packages/buildbot-0.8.3p1-py2.6.egg/buildbot/status/mail.py", line 293, in __init__
    assert interfaces.IEmailLookup.providedBy(lookup)
AssertionError


...或任何其他数量的问题,具体取决于我如何实现IEmailLookup接口。

我正在使用buildbot 0.8.3p1和python 2.6.1。

我看到了一些珍贵的示例,但在我看来,每个示例都失败了。我在这里想念什么?

最佳答案

我自己解决了这个问题。

首先,您需要添加(文件顶部的某个位置)

from zope.interface import implements


然后改变

__implements__ = interfaces.IEmailLookup




if implements:
    implements( interfaces.IEmailLookup )
else:
    __implements__ = interfaces.IEmailLookup

10-07 21:35