コード例 #1
0
ファイル: webhook.py プロジェクト: aether-space/trompet
    def create(self, service, project, config, observer):
        message_format = string.Template(config["message"])
        resource = service.get_resource_for_project(project)
        child = WebhookListener(
            project, observer, message_format, self.commit_extractor,
            config.get("max commit messages per push"))
        resource.putChild(self.name, child)

class BitbucketListenerFactory(WebhookListenerFactory):
    name = u"bitbucket"
    commit_extractor = staticmethod(extract_bitbucket_commit)

class GitHubListenerFactory(WebhookListenerFactory):
    name = u"github"
    commit_extractor = staticmethod(extract_github_commit)

class TravisCIListenerFactory(object):
    name = u"travisci"

    def create(self, service, project, config, observer):
        message_format = string.Template(config["message"])
        travis_token = config["token"]
        resource = service.get_resource_for_project(project)
        child = TravisCIWebhookListener(project, observer, message_format,
                                        travis_token)
        resource.putChild(self.name, child)

registry.register(BitbucketListenerFactory())
registry.register(GitHubListenerFactory())
registry.register(TravisCIListenerFactory())
コード例 #2
0
ファイル: xmlrpc.py プロジェクト: RonnyPfannschmidt/trompet
# encoding: utf-8

from twisted.web import xmlrpc

from trompet.listeners import registry


class XMLRPCInterface(xmlrpc.XMLRPC):
    def __init__(self, project, observer, *args, **kwargs):
        xmlrpc.XMLRPC.__init__(self, *args, **kwargs)
        self.project = project
        self.observer = observer

    def xmlrpc_notify(self, message):
        self.observer.notify(self.project, message)
        return True


class ListenerFactory(object):
    name = u"xmlrpc"

    def create(self, service, project, config, observer):
        if config:
            resource = service.get_resource_for_project(project)
            resource.putChild("xmlrpc", XMLRPCInterface(project, observer))


listener_factory = ListenerFactory()
registry.register(listener_factory)