{"action":"created","comment":{"url":"https://api.github.com/repos/buildbot/buildbot/pulls/comments/37274116","id":37274116,"diff_hunk":"@@ -0,0 +1,104 @@\n+# This file is part of Buildbot.  Buildbot is free software: you can\n+# redistribute it and/or modify it under the terms of the GNU General Public\n+# License as published by the Free Software Foundation, version 2.\n+#\n+# This program is distributed in the hope that it will be useful, but WITHOUT\n+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\n+# details.\n+#\n+# You should have received a copy of the GNU General Public License along with\n+# this program; if not, write to the Free Software Foundation, Inc., 51\n+# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n+#\n+# Copyright Buildbot Team Members\n+\n+from autobahn.wamp.exception import TransportLost\n+from autobahn.wamp.types import PublishOptions\n+from autobahn.wamp.types import SubscribeOptions\n+\n+from twisted.internet import defer\n+\n+from buildbot.mq import base\n+from buildbot.util import service\n+from buildbot.util import toJson\n+from twisted.python import log\n+\n+import json\n+\n+\n+class WampMQ(service.ReconfigurableServiceMixin, base.MQBase):\n+    NAMESPACE = u\"org.buildbot.mq\"\n+\n+    def __init__(self):\n+        base.MQBase.__init__(self)\n+\n+    def produce(self, routingKey, data):\n+        d = self._produce(routingKey, data)\n+        d.addErrback(log.err, \"Problem while producing message on topic \" + repr(routingKey))\n+\n+    @classmethod\n+    def messageTopic(cls, routingKey):\n+        ifNone = lambda v, default: default if v is None else v\n+        return cls.NAMESPACE + u\".\" + u\".\".join([ifNone(key, \"\") for key in routingKey])\n+\n+    @classmethod\n+    def routingKeyFromMessageTopic(cls, topic):\n+        return tuple(topic[len(WampMQ.NAMESPACE) + 1:].split(\".\"))\n+\n+    def _produce(self, routingKey, data):\n+        _data = json.loads(json.dumps(data, default=toJson))\n+        options = PublishOptions(exclude_me=False)\n+        return self.master.wamp.publish(self.messageTopic(routingKey), _data, options=options)\n+\n+    def startConsuming(self, callback, _filter, persistent_name=None):\n+        if persistent_name is not None:\n+            print \"wampmq: persistant queues are not persisted!\", persistent_name, _filter\n+\n+        qr = QueueRef(callback)\n+\n+        self._startConsuming(qr, callback, _filter)\n+        return defer.succeed(qr)\n+\n+    def _startConsuming(self, qr, callback, _filter, persistent_name=None):\n+        return qr.subscribe(self.master.wamp, _filter)\n+\n+\n+class QueueRef(base.QueueRef):\n+\n+    def __init__(self, callback):\n+        base.QueueRef.__init__(self, callback)\n+        self.unreg = None\n+\n+    @defer.inlineCallbacks\n+    def subscribe(self, service, _filter):\n+        self.filter = _filter\n+        self.emulated = False\n+        options = dict(details_arg='details')\n+        if None in _filter:\n+            options[\"match\"] = u\"wildcard\"","path":"master/buildbot/mq/wamp.py","position":79,"original_position":79,"commit_id":"85aadf3d5937682a3127eb7e2046fd0f214589d9","original_commit_id":"85aadf3d5937682a3127eb7e2046fd0f214589d9","user":{"login":"sa2ajj","id":447092,"avatar_url":"https://avatars.githubusercontent.com/u/447092?v=3","gravatar_id":"","url":"https://api.github.com/users/sa2ajj","html_url":"https://github.com/sa2ajj","followers_url":"https://api.github.com/users/sa2ajj/followers","following_url":"https://api.github.com/users/sa2ajj/following{/other_user}","gists_url":"https://api.github.com/users/sa2ajj/gists{/gist_id}","starred_url":"https://api.github.com/users/sa2ajj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sa2ajj/subscriptions","organizations_url":"https://api.github.com/users/sa2ajj/orgs","repos_url":"https://api.github.com/users/sa2ajj/repos","events_url":"https://api.github.com/users/sa2ajj/events{/privacy}","received_events_url":"https://api.github.com/users/sa2ajj/received_events","type":"User","site_admin":false},"body":"[nit] Can we enable unicode literals and forget these `u'...'`?","created_at":"2015-08-18T08:16:36Z","updated_at":"2015-08-18T08:16:36Z","html_url":"https://github.com/buildbot/buildbot/pull/1773#discussion_r37274116","pull_request_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1773","_links":{"self":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/comments/37274116"},"html":{"href":"https://github.com/buildbot/buildbot/pull/1773#discussion_r37274116"},"pull_request":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1773"}}},"pull_request":{"url":"https://api.github.com/repos/buildbot/buildbot/pulls/1773","id":40015916,"html_url":"https://github.com/buildbot/buildbot/pull/1773","diff_url":"https://github.com/buildbot/buildbot/pull/1773.diff","patch_url":"https://github.com/buildbot/buildbot/pull/1773.patch","issue_url":"https://api.github.com/repos/buildbot/buildbot/issues/1773","number":1773,"state":"open","locked":false,"title":"Wampmq","user":{"login":"tardyp","id":109859,"avatar_url":"https://avatars.githubusercontent.com/u/109859?v=3","gravatar_id":"","url":"https://api.github.com/users/tardyp","html_url":"https://github.com/tardyp","followers_url":"https://api.github.com/users/tardyp/followers","following_url":"https://api.github.com/users/tardyp/following{/other_user}","gists_url":"https://api.github.com/users/tardyp/gists{/gist_id}","starred_url":"https://api.github.com/users/tardyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tardyp/subscriptions","organizations_url":"https://api.github.com/users/tardyp/orgs","repos_url":"https://api.github.com/users/tardyp/repos","events_url":"https://api.github.com/users/tardyp/events{/privacy}","received_events_url":"https://api.github.com/users/tardyp/received_events","type":"User","site_admin":false},"body":"\r\nThis is a MQ implementation using [wamp](http://wamp.ws/)  protocol.\r\nThis implementation uses [Python Autobahn](http://autobahn.ws) wamp client library, and is fully asynchronous (no use of threads)\r\nTo use this implementation, you need a wamp router like [Crossbar](http://crossbar.io).\r\nThe implementation does not yet support wamp authentication yet.\r\nThis MQ allows buildbot to run in multi-master mode.\r\n\r\nNote that this implementation also does not support message persistence across a restart of the master.\r\nFor example, if a change is received, but the master shuts down before the schedulers can create build requests for it, then those schedulers will not be notified of the change when the master starts again.\r\n","created_at":"2015-07-15T12:15:26Z","updated_at":"2015-08-18T08:16:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ae0bd3c44acf9290f846584c42b454c0727d24f0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1773/commits","review_comments_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1773/comments","review_comment_url":"https://api.github.com/repos/buildbot/buildbot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/buildbot/buildbot/issues/1773/comments","statuses_url":"https://api.github.com/repos/buildbot/buildbot/statuses/85aadf3d5937682a3127eb7e2046fd0f214589d9","head":{"label":"tardyp:wampmq","ref":"wampmq","sha":"85aadf3d5937682a3127eb7e2046fd0f214589d9","user":{"login":"tardyp","id":109859,"avatar_url":"https://avatars.githubusercontent.com/u/109859?v=3","gravatar_id":"","url":"https://api.github.com/users/tardyp","html_url":"https://github.com/tardyp","followers_url":"https://api.github.com/users/tardyp/followers","following_url":"https://api.github.com/users/tardyp/following{/other_user}","gists_url":"https://api.github.com/users/tardyp/gists{/gist_id}","starred_url":"https://api.github.com/users/tardyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tardyp/subscriptions","organizations_url":"https://api.github.com/users/tardyp/orgs","repos_url":"https://api.github.com/users/tardyp/repos","events_url":"https://api.github.com/users/tardyp/events{/privacy}","received_events_url":"https://api.github.com/users/tardyp/received_events","type":"User","site_admin":false},"repo":{"id":930175,"name":"buildbot","full_name":"tardyp/buildbot","owner":{"login":"tardyp","id":109859,"avatar_url":"https://avatars.githubusercontent.com/u/109859?v=3","gravatar_id":"","url":"https://api.github.com/users/tardyp","html_url":"https://github.com/tardyp","followers_url":"https://api.github.com/users/tardyp/followers","following_url":"https://api.github.com/users/tardyp/following{/other_user}","gists_url":"https://api.github.com/users/tardyp/gists{/gist_id}","starred_url":"https://api.github.com/users/tardyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tardyp/subscriptions","organizations_url":"https://api.github.com/users/tardyp/orgs","repos_url":"https://api.github.com/users/tardyp/repos","events_url":"https://api.github.com/users/tardyp/events{/privacy}","received_events_url":"https://api.github.com/users/tardyp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tardyp/buildbot","description":"Python-based continuous integration testing framework; send pull requests for your patches!","fork":true,"url":"https://api.github.com/repos/tardyp/buildbot","forks_url":"https://api.github.com/repos/tardyp/buildbot/forks","keys_url":"https://api.github.com/repos/tardyp/buildbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tardyp/buildbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tardyp/buildbot/teams","hooks_url":"https://api.github.com/repos/tardyp/buildbot/hooks","issue_events_url":"https://api.github.com/repos/tardyp/buildbot/issues/events{/number}","events_url":"https://api.github.com/repos/tardyp/buildbot/events","assignees_url":"https://api.github.com/repos/tardyp/buildbot/assignees{/user}","branches_url":"https://api.github.com/repos/tardyp/buildbot/branches{/branch}","tags_url":"https://api.github.com/repos/tardyp/buildbot/tags","blobs_url":"https://api.github.com/repos/tardyp/buildbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tardyp/buildbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tardyp/buildbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/tardyp/buildbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tardyp/buildbot/statuses/{sha}","languages_url":"https://api.github.com/repos/tardyp/buildbot/languages","stargazers_url":"https://api.github.com/repos/tardyp/buildbot/stargazers","contributors_url":"https://api.github.com/repos/tardyp/buildbot/contributors","subscribers_url":"https://api.github.com/repos/tardyp/buildbot/subscribers","subscription_url":"https://api.github.com/repos/tardyp/buildbot/subscription","commits_url":"https://api.github.com/repos/tardyp/buildbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/tardyp/buildbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/tardyp/buildbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/tardyp/buildbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/tardyp/buildbot/contents/{+path}","compare_url":"https://api.github.com/repos/tardyp/buildbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tardyp/buildbot/merges","archive_url":"https://api.github.com/repos/tardyp/buildbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tardyp/buildbot/downloads","issues_url":"https://api.github.com/repos/tardyp/buildbot/issues{/number}","pulls_url":"https://api.github.com/repos/tardyp/buildbot/pulls{/number}","milestones_url":"https://api.github.com/repos/tardyp/buildbot/milestones{/number}","notifications_url":"https://api.github.com/repos/tardyp/buildbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tardyp/buildbot/labels{/name}","releases_url":"https://api.github.com/repos/tardyp/buildbot/releases{/id}","created_at":"2010-09-22T09:33:50Z","updated_at":"2014-06-24T21:37:41Z","pushed_at":"2015-08-16T14:11:15Z","git_url":"git://github.com/tardyp/buildbot.git","ssh_url":"git@github.com:tardyp/buildbot.git","clone_url":"https://github.com/tardyp/buildbot.git","svn_url":"https://github.com/tardyp/buildbot","homepage":"http://buildbot.net","size":38327,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":4,"default_branch":"nine"}},"base":{"label":"buildbot:master","ref":"master","sha":"6abcca42c9b95a7b6184bd06687e94dd3cc0f0f1","user":{"login":"buildbot","id":324515,"avatar_url":"https://avatars.githubusercontent.com/u/324515?v=3","gravatar_id":"","url":"https://api.github.com/users/buildbot","html_url":"https://github.com/buildbot","followers_url":"https://api.github.com/users/buildbot/followers","following_url":"https://api.github.com/users/buildbot/following{/other_user}","gists_url":"https://api.github.com/users/buildbot/gists{/gist_id}","starred_url":"https://api.github.com/users/buildbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buildbot/subscriptions","organizations_url":"https://api.github.com/users/buildbot/orgs","repos_url":"https://api.github.com/users/buildbot/repos","events_url":"https://api.github.com/users/buildbot/events{/privacy}","received_events_url":"https://api.github.com/users/buildbot/received_events","type":"Organization","site_admin":false},"repo":{"id":760165,"name":"buildbot","full_name":"buildbot/buildbot","owner":{"login":"buildbot","id":324515,"avatar_url":"https://avatars.githubusercontent.com/u/324515?v=3","gravatar_id":"","url":"https://api.github.com/users/buildbot","html_url":"https://github.com/buildbot","followers_url":"https://api.github.com/users/buildbot/followers","following_url":"https://api.github.com/users/buildbot/following{/other_user}","gists_url":"https://api.github.com/users/buildbot/gists{/gist_id}","starred_url":"https://api.github.com/users/buildbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buildbot/subscriptions","organizations_url":"https://api.github.com/users/buildbot/orgs","repos_url":"https://api.github.com/users/buildbot/repos","events_url":"https://api.github.com/users/buildbot/events{/privacy}","received_events_url":"https://api.github.com/users/buildbot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/buildbot/buildbot","description":"Python-based continuous integration testing framework; your pull requests are more than welcome!","fork":false,"url":"https://api.github.com/repos/buildbot/buildbot","forks_url":"https://api.github.com/repos/buildbot/buildbot/forks","keys_url":"https://api.github.com/repos/buildbot/buildbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/buildbot/buildbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/buildbot/buildbot/teams","hooks_url":"https://api.github.com/repos/buildbot/buildbot/hooks","issue_events_url":"https://api.github.com/repos/buildbot/buildbot/issues/events{/number}","events_url":"https://api.github.com/repos/buildbot/buildbot/events","assignees_url":"https://api.github.com/repos/buildbot/buildbot/assignees{/user}","branches_url":"https://api.github.com/repos/buildbot/buildbot/branches{/branch}","tags_url":"https://api.github.com/repos/buildbot/buildbot/tags","blobs_url":"https://api.github.com/repos/buildbot/buildbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/buildbot/buildbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/buildbot/buildbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/buildbot/buildbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/buildbot/buildbot/statuses/{sha}","languages_url":"https://api.github.com/repos/buildbot/buildbot/languages","stargazers_url":"https://api.github.com/repos/buildbot/buildbot/stargazers","contributors_url":"https://api.github.com/repos/buildbot/buildbot/contributors","subscribers_url":"https://api.github.com/repos/buildbot/buildbot/subscribers","subscription_url":"https://api.github.com/repos/buildbot/buildbot/subscription","commits_url":"https://api.github.com/repos/buildbot/buildbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/buildbot/buildbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/buildbot/buildbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/buildbot/buildbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/buildbot/buildbot/contents/{+path}","compare_url":"https://api.github.com/repos/buildbot/buildbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/buildbot/buildbot/merges","archive_url":"https://api.github.com/repos/buildbot/buildbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/buildbot/buildbot/downloads","issues_url":"https://api.github.com/repos/buildbot/buildbot/issues{/number}","pulls_url":"https://api.github.com/repos/buildbot/buildbot/pulls{/number}","milestones_url":"https://api.github.com/repos/buildbot/buildbot/milestones{/number}","notifications_url":"https://api.github.com/repos/buildbot/buildbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/buildbot/buildbot/labels{/name}","releases_url":"https://api.github.com/repos/buildbot/buildbot/releases{/id}","created_at":"2010-07-06T17:56:53Z","updated_at":"2015-08-17T00:52:48Z","pushed_at":"2015-08-18T07:22:29Z","git_url":"git://github.com/buildbot/buildbot.git","ssh_url":"git@github.com:buildbot/buildbot.git","clone_url":"https://github.com/buildbot/buildbot.git","svn_url":"https://github.com/buildbot/buildbot","homepage":"http://buildbot.net","size":52533,"stargazers_count":1689,"watchers_count":1689,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":744,"mirror_url":null,"open_issues_count":23,"forks":744,"open_issues":23,"watchers":1689,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1773"},"html":{"href":"https://github.com/buildbot/buildbot/pull/1773"},"issue":{"href":"https://api.github.com/repos/buildbot/buildbot/issues/1773"},"comments":{"href":"https://api.github.com/repos/buildbot/buildbot/issues/1773/comments"},"review_comments":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1773/comments"},"review_comment":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1773/commits"},"statuses":{"href":"https://api.github.com/repos/buildbot/buildbot/statuses/85aadf3d5937682a3127eb7e2046fd0f214589d9"}}}}