{"action":"created","comment":{"url":"https://api.github.com/repos/cylc/cylc/pulls/comments/25949221","id":25949221,"diff_hunk":"@@ -0,0 +1,181 @@\n+#!/usr/bin/env python\n+\n+# THIS FILE IS PART OF THE CYLC SUITE ENGINE.\n+# Copyright (C) 2008-2015 NIWA\n+#\n+# This program is free software: you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation, either version 3 of the License, or\n+# (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+\n+import sys\n+import time\n+import logging\n+import Queue\n+import Pyro.core\n+import Pyro.errors\n+import cylc.flags\n+import cylc.cylc_pyro_client\n+from cylc.task_id import TaskID\n+from cylc.passphrase import passphrase\n+\n+\n+PYRO_TARGET_NAME = 'external_event_broker'\n+\n+\n+class PyroClient(object):\n+    \"\"\"Network client for sending external triggers to a suite.\"\"\"\n+\n+    # TODO - configurable network retry parameters?\n+    MAX_TRIES = 5\n+    PYRO_TIMEOUT = 10\n+    RETRY_SECONDS = 10\n+\n+    def __init__(\n+            self, suite, event_msg, host='localhost', owner=None,\n+            port=None, event_id=None):\n+\n+        self.event_msg = event_msg\n+        self.event_id = event_id\n+        self.suite = suite\n+        self.host = host\n+        self.owner = owner\n+        self.port = port\n+\n+        self.pphrase = passphrase(\n+                self.suite, self.owner, self.host).get(None, None)\n+\n+        self.pyro_proxy = cylc.cylc_pyro_client.client(\n+                self.suite, self.pphrase,\n+                self.owner, self.host, self.__class__.PYRO_TIMEOUT,\n+                self.port ).get_proxy(PYRO_TARGET_NAME)\n+\n+    def send(self):\n+        sent = False\n+        itry = 0\n+        while True:\n+            itry += 1\n+            try:\n+                # Get a proxy for the remote object and send the message.\n+                self.pyro_proxy.register(self.event_msg, self.event_id)\n+            except Pyro.errors.NamingError as exc:\n+                print >> sys.stderr, exc\n+                print \"Send message: try %s of %s failed: %s\" % (","path":"lib/cylc/external_trigger.py","position":71,"original_position":71,"commit_id":"a036797ba4e22385962ae6a1960b7c8c1e4134d2","original_commit_id":"a036797ba4e22385962ae6a1960b7c8c1e4134d2","user":{"login":"arjclark","id":2562650,"avatar_url":"https://avatars.githubusercontent.com/u/2562650?v=3","gravatar_id":"","url":"https://api.github.com/users/arjclark","html_url":"https://github.com/arjclark","followers_url":"https://api.github.com/users/arjclark/followers","following_url":"https://api.github.com/users/arjclark/following{/other_user}","gists_url":"https://api.github.com/users/arjclark/gists{/gist_id}","starred_url":"https://api.github.com/users/arjclark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arjclark/subscriptions","organizations_url":"https://api.github.com/users/arjclark/orgs","repos_url":"https://api.github.com/users/arjclark/repos","events_url":"https://api.github.com/users/arjclark/events{/privacy}","received_events_url":"https://api.github.com/users/arjclark/received_events","type":"User","site_admin":false},"body":"This message could be a class level variable as it's used several times e.g. `ERROR_FAILED_SEND=\"Send message: try %s of %s failed: %s\"`.","created_at":"2015-03-06T14:57:38Z","updated_at":"2015-03-06T14:57:38Z","html_url":"https://github.com/cylc/cylc/pull/1316#discussion_r25949221","pull_request_url":"https://api.github.com/repos/cylc/cylc/pulls/1316","_links":{"self":{"href":"https://api.github.com/repos/cylc/cylc/pulls/comments/25949221"},"html":{"href":"https://github.com/cylc/cylc/pull/1316#discussion_r25949221"},"pull_request":{"href":"https://api.github.com/repos/cylc/cylc/pulls/1316"}}},"pull_request":{"url":"https://api.github.com/repos/cylc/cylc/pulls/1316","id":28913313,"html_url":"https://github.com/cylc/cylc/pull/1316","diff_url":"https://github.com/cylc/cylc/pull/1316.diff","patch_url":"https://github.com/cylc/cylc/pull/1316.patch","issue_url":"https://api.github.com/repos/cylc/cylc/issues/1316","number":1316,"state":"open","locked":false,"title":"1188 External event triggers","user":{"login":"hjoliver","id":2362137,"avatar_url":"https://avatars.githubusercontent.com/u/2362137?v=3","gravatar_id":"","url":"https://api.github.com/users/hjoliver","html_url":"https://github.com/hjoliver","followers_url":"https://api.github.com/users/hjoliver/followers","following_url":"https://api.github.com/users/hjoliver/following{/other_user}","gists_url":"https://api.github.com/users/hjoliver/gists{/gist_id}","starred_url":"https://api.github.com/users/hjoliver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hjoliver/subscriptions","organizations_url":"https://api.github.com/users/hjoliver/orgs","repos_url":"https://api.github.com/users/hjoliver/repos","events_url":"https://api.github.com/users/hjoliver/events{/privacy}","received_events_url":"https://api.github.com/users/hjoliver/received_events","type":"User","site_admin":false},"body":"Prototype implementation of #1188.\r\n\r\n@matthewrmshin et. al. - Not for final review yet, please consider the implementation in light of my explanatory comments in https://github.com/cylc/cylc/issues/1188#issuecomment-73492947. Note in particular the working example suite in ```examples/satellite/ext-triggers```.  I'll refrain from documenting this or tidying it up until we agree that this is the right approach.","created_at":"2015-02-09T11:31:07Z","updated_at":"2015-03-06T14:57:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8c7480d0d91d8e59c324ae7b65fad4fc3686030c","assignee":{"login":"arjclark","id":2562650,"avatar_url":"https://avatars.githubusercontent.com/u/2562650?v=3","gravatar_id":"","url":"https://api.github.com/users/arjclark","html_url":"https://github.com/arjclark","followers_url":"https://api.github.com/users/arjclark/followers","following_url":"https://api.github.com/users/arjclark/following{/other_user}","gists_url":"https://api.github.com/users/arjclark/gists{/gist_id}","starred_url":"https://api.github.com/users/arjclark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arjclark/subscriptions","organizations_url":"https://api.github.com/users/arjclark/orgs","repos_url":"https://api.github.com/users/arjclark/repos","events_url":"https://api.github.com/users/arjclark/events{/privacy}","received_events_url":"https://api.github.com/users/arjclark/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/cylc/cylc/milestones/5","html_url":"https://github.com/cylc/cylc/milestones/soon","labels_url":"https://api.github.com/repos/cylc/cylc/milestones/5/labels","id":262614,"number":5,"title":"soon","description":"A few months in the future. Top priority issues and easy fixes should initially be marked against this milestone, and then moved to *next-release* if work progresses quickly enough.","creator":{"login":"hjoliver","id":2362137,"avatar_url":"https://avatars.githubusercontent.com/u/2362137?v=3","gravatar_id":"","url":"https://api.github.com/users/hjoliver","html_url":"https://github.com/hjoliver","followers_url":"https://api.github.com/users/hjoliver/followers","following_url":"https://api.github.com/users/hjoliver/following{/other_user}","gists_url":"https://api.github.com/users/hjoliver/gists{/gist_id}","starred_url":"https://api.github.com/users/hjoliver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hjoliver/subscriptions","organizations_url":"https://api.github.com/users/hjoliver/orgs","repos_url":"https://api.github.com/users/hjoliver/repos","events_url":"https://api.github.com/users/hjoliver/events{/privacy}","received_events_url":"https://api.github.com/users/hjoliver/received_events","type":"User","site_admin":false},"open_issues":61,"closed_issues":0,"state":"open","created_at":"2013-02-08T07:07:13Z","updated_at":"2015-03-05T12:50:21Z","due_on":"2015-05-30T23:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/cylc/cylc/pulls/1316/commits","review_comments_url":"https://api.github.com/repos/cylc/cylc/pulls/1316/comments","review_comment_url":"https://api.github.com/repos/cylc/cylc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cylc/cylc/issues/1316/comments","statuses_url":"https://api.github.com/repos/cylc/cylc/statuses/a036797ba4e22385962ae6a1960b7c8c1e4134d2","head":{"label":"hjoliver:external-triggers","ref":"external-triggers","sha":"a036797ba4e22385962ae6a1960b7c8c1e4134d2","user":{"login":"hjoliver","id":2362137,"avatar_url":"https://avatars.githubusercontent.com/u/2362137?v=3","gravatar_id":"","url":"https://api.github.com/users/hjoliver","html_url":"https://github.com/hjoliver","followers_url":"https://api.github.com/users/hjoliver/followers","following_url":"https://api.github.com/users/hjoliver/following{/other_user}","gists_url":"https://api.github.com/users/hjoliver/gists{/gist_id}","starred_url":"https://api.github.com/users/hjoliver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hjoliver/subscriptions","organizations_url":"https://api.github.com/users/hjoliver/orgs","repos_url":"https://api.github.com/users/hjoliver/repos","events_url":"https://api.github.com/users/hjoliver/events{/privacy}","received_events_url":"https://api.github.com/users/hjoliver/received_events","type":"User","site_admin":false},"repo":{"id":5840564,"name":"cylc","full_name":"hjoliver/cylc","owner":{"login":"hjoliver","id":2362137,"avatar_url":"https://avatars.githubusercontent.com/u/2362137?v=3","gravatar_id":"","url":"https://api.github.com/users/hjoliver","html_url":"https://github.com/hjoliver","followers_url":"https://api.github.com/users/hjoliver/followers","following_url":"https://api.github.com/users/hjoliver/following{/other_user}","gists_url":"https://api.github.com/users/hjoliver/gists{/gist_id}","starred_url":"https://api.github.com/users/hjoliver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hjoliver/subscriptions","organizations_url":"https://api.github.com/users/hjoliver/orgs","repos_url":"https://api.github.com/users/hjoliver/repos","events_url":"https://api.github.com/users/hjoliver/events{/privacy}","received_events_url":"https://api.github.com/users/hjoliver/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hjoliver/cylc","description":"My fork of the cylc suite engine. The central repository is here:","fork":true,"url":"https://api.github.com/repos/hjoliver/cylc","forks_url":"https://api.github.com/repos/hjoliver/cylc/forks","keys_url":"https://api.github.com/repos/hjoliver/cylc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hjoliver/cylc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hjoliver/cylc/teams","hooks_url":"https://api.github.com/repos/hjoliver/cylc/hooks","issue_events_url":"https://api.github.com/repos/hjoliver/cylc/issues/events{/number}","events_url":"https://api.github.com/repos/hjoliver/cylc/events","assignees_url":"https://api.github.com/repos/hjoliver/cylc/assignees{/user}","branches_url":"https://api.github.com/repos/hjoliver/cylc/branches{/branch}","tags_url":"https://api.github.com/repos/hjoliver/cylc/tags","blobs_url":"https://api.github.com/repos/hjoliver/cylc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hjoliver/cylc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hjoliver/cylc/git/refs{/sha}","trees_url":"https://api.github.com/repos/hjoliver/cylc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hjoliver/cylc/statuses/{sha}","languages_url":"https://api.github.com/repos/hjoliver/cylc/languages","stargazers_url":"https://api.github.com/repos/hjoliver/cylc/stargazers","contributors_url":"https://api.github.com/repos/hjoliver/cylc/contributors","subscribers_url":"https://api.github.com/repos/hjoliver/cylc/subscribers","subscription_url":"https://api.github.com/repos/hjoliver/cylc/subscription","commits_url":"https://api.github.com/repos/hjoliver/cylc/commits{/sha}","git_commits_url":"https://api.github.com/repos/hjoliver/cylc/git/commits{/sha}","comments_url":"https://api.github.com/repos/hjoliver/cylc/comments{/number}","issue_comment_url":"https://api.github.com/repos/hjoliver/cylc/issues/comments{/number}","contents_url":"https://api.github.com/repos/hjoliver/cylc/contents/{+path}","compare_url":"https://api.github.com/repos/hjoliver/cylc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hjoliver/cylc/merges","archive_url":"https://api.github.com/repos/hjoliver/cylc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hjoliver/cylc/downloads","issues_url":"https://api.github.com/repos/hjoliver/cylc/issues{/number}","pulls_url":"https://api.github.com/repos/hjoliver/cylc/pulls{/number}","milestones_url":"https://api.github.com/repos/hjoliver/cylc/milestones{/number}","notifications_url":"https://api.github.com/repos/hjoliver/cylc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hjoliver/cylc/labels{/name}","releases_url":"https://api.github.com/repos/hjoliver/cylc/releases{/id}","created_at":"2012-09-17T12:20:56Z","updated_at":"2015-02-11T11:01:08Z","pushed_at":"2015-03-03T01:41:37Z","git_url":"git://github.com/hjoliver/cylc.git","ssh_url":"git@github.com:hjoliver/cylc.git","clone_url":"https://github.com/hjoliver/cylc.git","svn_url":"https://github.com/hjoliver/cylc","homepage":"http://cylc.github.com/cylc","size":71392,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"cylc:master","ref":"master","sha":"7023810f1c402bc5949cafdcc39d5bc0ec66adae","user":{"login":"cylc","id":824878,"avatar_url":"https://avatars.githubusercontent.com/u/824878?v=3","gravatar_id":"","url":"https://api.github.com/users/cylc","html_url":"https://github.com/cylc","followers_url":"https://api.github.com/users/cylc/followers","following_url":"https://api.github.com/users/cylc/following{/other_user}","gists_url":"https://api.github.com/users/cylc/gists{/gist_id}","starred_url":"https://api.github.com/users/cylc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cylc/subscriptions","organizations_url":"https://api.github.com/users/cylc/orgs","repos_url":"https://api.github.com/users/cylc/repos","events_url":"https://api.github.com/users/cylc/events{/privacy}","received_events_url":"https://api.github.com/users/cylc/received_events","type":"Organization","site_admin":false},"repo":{"id":1836229,"name":"cylc","full_name":"cylc/cylc","owner":{"login":"cylc","id":824878,"avatar_url":"https://avatars.githubusercontent.com/u/824878?v=3","gravatar_id":"","url":"https://api.github.com/users/cylc","html_url":"https://github.com/cylc","followers_url":"https://api.github.com/users/cylc/followers","following_url":"https://api.github.com/users/cylc/following{/other_user}","gists_url":"https://api.github.com/users/cylc/gists{/gist_id}","starred_url":"https://api.github.com/users/cylc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cylc/subscriptions","organizations_url":"https://api.github.com/users/cylc/orgs","repos_url":"https://api.github.com/users/cylc/repos","events_url":"https://api.github.com/users/cylc/events{/privacy}","received_events_url":"https://api.github.com/users/cylc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cylc/cylc","description":"This is the official repository of the cylc suite engine. It will normally contain just the master branch, with completed features merged in from feature branches in developer forks.","fork":false,"url":"https://api.github.com/repos/cylc/cylc","forks_url":"https://api.github.com/repos/cylc/cylc/forks","keys_url":"https://api.github.com/repos/cylc/cylc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cylc/cylc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cylc/cylc/teams","hooks_url":"https://api.github.com/repos/cylc/cylc/hooks","issue_events_url":"https://api.github.com/repos/cylc/cylc/issues/events{/number}","events_url":"https://api.github.com/repos/cylc/cylc/events","assignees_url":"https://api.github.com/repos/cylc/cylc/assignees{/user}","branches_url":"https://api.github.com/repos/cylc/cylc/branches{/branch}","tags_url":"https://api.github.com/repos/cylc/cylc/tags","blobs_url":"https://api.github.com/repos/cylc/cylc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cylc/cylc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cylc/cylc/git/refs{/sha}","trees_url":"https://api.github.com/repos/cylc/cylc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cylc/cylc/statuses/{sha}","languages_url":"https://api.github.com/repos/cylc/cylc/languages","stargazers_url":"https://api.github.com/repos/cylc/cylc/stargazers","contributors_url":"https://api.github.com/repos/cylc/cylc/contributors","subscribers_url":"https://api.github.com/repos/cylc/cylc/subscribers","subscription_url":"https://api.github.com/repos/cylc/cylc/subscription","commits_url":"https://api.github.com/repos/cylc/cylc/commits{/sha}","git_commits_url":"https://api.github.com/repos/cylc/cylc/git/commits{/sha}","comments_url":"https://api.github.com/repos/cylc/cylc/comments{/number}","issue_comment_url":"https://api.github.com/repos/cylc/cylc/issues/comments{/number}","contents_url":"https://api.github.com/repos/cylc/cylc/contents/{+path}","compare_url":"https://api.github.com/repos/cylc/cylc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cylc/cylc/merges","archive_url":"https://api.github.com/repos/cylc/cylc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cylc/cylc/downloads","issues_url":"https://api.github.com/repos/cylc/cylc/issues{/number}","pulls_url":"https://api.github.com/repos/cylc/cylc/pulls{/number}","milestones_url":"https://api.github.com/repos/cylc/cylc/milestones{/number}","notifications_url":"https://api.github.com/repos/cylc/cylc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cylc/cylc/labels{/name}","releases_url":"https://api.github.com/repos/cylc/cylc/releases{/id}","created_at":"2011-06-02T08:31:49Z","updated_at":"2015-03-04T11:58:32Z","pushed_at":"2015-03-04T11:58:32Z","git_url":"git://github.com/cylc/cylc.git","ssh_url":"git@github.com:cylc/cylc.git","clone_url":"https://github.com/cylc/cylc.git","svn_url":"https://github.com/cylc/cylc","homepage":"http://cylc.github.com/cylc","size":86988,"stargazers_count":24,"watchers_count":24,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":16,"mirror_url":null,"open_issues_count":167,"forks":16,"open_issues":167,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cylc/cylc/pulls/1316"},"html":{"href":"https://github.com/cylc/cylc/pull/1316"},"issue":{"href":"https://api.github.com/repos/cylc/cylc/issues/1316"},"comments":{"href":"https://api.github.com/repos/cylc/cylc/issues/1316/comments"},"review_comments":{"href":"https://api.github.com/repos/cylc/cylc/pulls/1316/comments"},"review_comment":{"href":"https://api.github.com/repos/cylc/cylc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cylc/cylc/pulls/1316/commits"},"statuses":{"href":"https://api.github.com/repos/cylc/cylc/statuses/a036797ba4e22385962ae6a1960b7c8c1e4134d2"}}}}