{"action":"created","comment":{"url":"https://api.github.com/repos/park-bench/confighelper/pulls/comments/228787044","pull_request_review_id":169134346,"id":228787044,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODc4NzA0NA==","diff_hunk":"@@ -0,0 +1,138 @@\n+# Copyright 2017-2018 Joel Allen Luellwitz and Andrew Klapp\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+\"\"\"Provides the broadcasting component of a filesystem-based IPC mechanism.\"\"\"\n+\n+__all__ = ['BroadcasterBroadcastException',\n+           'BroadcasterInitException',\n+           'Broadcaster']\n+\n+import datetime\n+import logging\n+import os\n+import stat\n+import traceback\n+import tmpfs\n+\n+TMPFS_SIZE = '1M'\n+\n+class BroadcasterBroadcastException(Exception):\n+    \"\"\"This exception is raised when a BeaconBroadcaster object fails to issue a broadcast.\"\"\"\n+\n+class BroadcasterInitException(Exception):\n+    \"\"\"This exception is raised when a BeaconBroadcaster object fails to initialize.\"\"\"\n+\n+class Broadcaster(object):\n+    \"\"\"Provides the broadcasting component of a filesystem-based IPC mechanism.\"\"\"\n+\n+    def __init__(self, program_name, broadcast_name, uid, gid):\n+        \"\"\"Initial configuration of the broadcast directory. This must be done as root. This\n+        method creates any necessary spool directories, sets their permissions, and mounts a\n+        ramdisk if necessary.\n+\n+        program_name: The name of the program issuing the broadcast.\n+        broadcast_name: The name of the broadcast to issue.\n+        uid: The UID of the calling program.\n+        gid: The GID of the calling program.\n+        \"\"\"\n+\n+        self.logger = logging.getLogger(__name__)\n+\n+        self.logger.debug(\"Initializing broadcaster for broadcast %s from program %s.\",\n+                          broadcast_name, program_name)\n+\n+\n+        broadcast_path = '/var/spool/'\n+        self.broadcast_path = os.path.join(broadcast_path, program_name, broadcast_name)\n+        self.program_name = program_name\n+        self.broadcast_name = broadcast_name\n+\n+        tmpfs_path = os.path.join(broadcast_path, program_name)\n+        tmpfs.mount_tmpfs(tmpfs_path, TMPFS_SIZE)\n+\n+        self._create_directory(self.broadcast_path)\n+        # Set permissions to xrw-------\n+        group_rw_mode = stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXGRP | stat.S_IRGRP\n+        self._set_file_permissions(self.broadcast_path, group_rw_mode, uid, gid)\n+\n+        self.logger.info(\"Broadcaster for eacon %s from program %s initialized.\",\n+                         broadcast_name, program_name)\n+\n+    def issue(self):\n+        \"\"\"Place a new file in the broadcast directory. Will raise an exception if it fails.\"\"\"\n+        self.logger.info(\n+            \"Sending broadcast %s for program %s.\", self.broadcast_name, self.program_name)\n+        now = datetime.datetime.now().isoformat()\n+        random_number = os.urandom(16).encode('hex')\n+\n+        broadcast_filename = '%s---%s' % (now, random_number)\n+        final_path = os.path.join(self.broadcast_path, broadcast_filename)\n+\n+        try:\n+            previous_broadcasts = os.listdir(self.broadcast_path)\n+            open(final_path, 'a').close()\n+\n+            for broadcast_file in previous_broadcasts:\n+                os.remove(os.path.join(self.broadcast_path, broadcast_file))\n+\n+        except Exception as exception:\n+            message = \\\n+                'Could not create broadcast file for broadcast %s, program %s. %s:%s\\n%s' \\\n+                % (self.broadcast_name, self.program_name, type(exception).__name__,\n+                   str(exception), traceback.format_exc())\n+            self.logger.critical(message)","path":"parkbenchcommon/broadcaster.py","position":95,"original_position":95,"commit_id":"5f86b62ea928a9d0244b0fbd743dba849a3b050e","original_commit_id":"5f86b62ea928a9d0244b0fbd743dba849a3b050e","user":{"login":"eviljoel","id":322282,"node_id":"MDQ6VXNlcjMyMjI4Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/322282?v=4","gravatar_id":"","url":"https://api.github.com/users/eviljoel","html_url":"https://github.com/eviljoel","followers_url":"https://api.github.com/users/eviljoel/followers","following_url":"https://api.github.com/users/eviljoel/following{/other_user}","gists_url":"https://api.github.com/users/eviljoel/gists{/gist_id}","starred_url":"https://api.github.com/users/eviljoel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eviljoel/subscriptions","organizations_url":"https://api.github.com/users/eviljoel/orgs","repos_url":"https://api.github.com/users/eviljoel/repos","events_url":"https://api.github.com/users/eviljoel/events{/privacy}","received_events_url":"https://api.github.com/users/eviljoel/received_events","type":"User","site_admin":false},"body":"We can't be sure the program is crashing. This should be error.","created_at":"2018-10-29T03:09:36Z","updated_at":"2018-10-29T03:09:36Z","html_url":"https://github.com/park-bench/confighelper/pull/15#discussion_r228787044","pull_request_url":"https://api.github.com/repos/park-bench/confighelper/pulls/15","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/park-bench/confighelper/pulls/comments/228787044"},"html":{"href":"https://github.com/park-bench/confighelper/pull/15#discussion_r228787044"},"pull_request":{"href":"https://api.github.com/repos/park-bench/confighelper/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/park-bench/confighelper/pulls/15","id":223080583,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzMDgwNTgz","html_url":"https://github.com/park-bench/confighelper/pull/15","diff_url":"https://github.com/park-bench/confighelper/pull/15.diff","patch_url":"https://github.com/park-bench/confighelper/pull/15.patch","issue_url":"https://api.github.com/repos/park-bench/confighelper/issues/15","number":15,"state":"open","locked":false,"title":"Beacon","user":{"login":"andklapp","id":5260293,"node_id":"MDQ6VXNlcjUyNjAyOTM=","avatar_url":"https://avatars3.githubusercontent.com/u/5260293?v=4","gravatar_id":"","url":"https://api.github.com/users/andklapp","html_url":"https://github.com/andklapp","followers_url":"https://api.github.com/users/andklapp/followers","following_url":"https://api.github.com/users/andklapp/following{/other_user}","gists_url":"https://api.github.com/users/andklapp/gists{/gist_id}","starred_url":"https://api.github.com/users/andklapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andklapp/subscriptions","organizations_url":"https://api.github.com/users/andklapp/orgs","repos_url":"https://api.github.com/users/andklapp/repos","events_url":"https://api.github.com/users/andklapp/events{/privacy}","received_events_url":"https://api.github.com/users/andklapp/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-10-16T00:21:43Z","updated_at":"2018-10-29T03:09:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9bd7c70cd33ba904a1104503871811cadc81b7df","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/park-bench/confighelper/pulls/15/commits","review_comments_url":"https://api.github.com/repos/park-bench/confighelper/pulls/15/comments","review_comment_url":"https://api.github.com/repos/park-bench/confighelper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/park-bench/confighelper/issues/15/comments","statuses_url":"https://api.github.com/repos/park-bench/confighelper/statuses/5f86b62ea928a9d0244b0fbd743dba849a3b050e","head":{"label":"park-bench:beacon","ref":"beacon","sha":"5f86b62ea928a9d0244b0fbd743dba849a3b050e","user":{"login":"park-bench","id":13323173,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMzIzMTcz","avatar_url":"https://avatars0.githubusercontent.com/u/13323173?v=4","gravatar_id":"","url":"https://api.github.com/users/park-bench","html_url":"https://github.com/park-bench","followers_url":"https://api.github.com/users/park-bench/followers","following_url":"https://api.github.com/users/park-bench/following{/other_user}","gists_url":"https://api.github.com/users/park-bench/gists{/gist_id}","starred_url":"https://api.github.com/users/park-bench/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/park-bench/subscriptions","organizations_url":"https://api.github.com/users/park-bench/orgs","repos_url":"https://api.github.com/users/park-bench/repos","events_url":"https://api.github.com/users/park-bench/events{/privacy}","received_events_url":"https://api.github.com/users/park-bench/received_events","type":"Organization","site_admin":false},"repo":{"id":42688971,"node_id":"MDEwOlJlcG9zaXRvcnk0MjY4ODk3MQ==","name":"confighelper","full_name":"park-bench/confighelper","private":false,"owner":{"login":"park-bench","id":13323173,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMzIzMTcz","avatar_url":"https://avatars0.githubusercontent.com/u/13323173?v=4","gravatar_id":"","url":"https://api.github.com/users/park-bench","html_url":"https://github.com/park-bench","followers_url":"https://api.github.com/users/park-bench/followers","following_url":"https://api.github.com/users/park-bench/following{/other_user}","gists_url":"https://api.github.com/users/park-bench/gists{/gist_id}","starred_url":"https://api.github.com/users/park-bench/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/park-bench/subscriptions","organizations_url":"https://api.github.com/users/park-bench/orgs","repos_url":"https://api.github.com/users/park-bench/repos","events_url":"https://api.github.com/users/park-bench/events{/privacy}","received_events_url":"https://api.github.com/users/park-bench/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/park-bench/confighelper","description":"Helps parse Parkbench configuration files.","fork":false,"url":"https://api.github.com/repos/park-bench/confighelper","forks_url":"https://api.github.com/repos/park-bench/confighelper/forks","keys_url":"https://api.github.com/repos/park-bench/confighelper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/park-bench/confighelper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/park-bench/confighelper/teams","hooks_url":"https://api.github.com/repos/park-bench/confighelper/hooks","issue_events_url":"https://api.github.com/repos/park-bench/confighelper/issues/events{/number}","events_url":"https://api.github.com/repos/park-bench/confighelper/events","assignees_url":"https://api.github.com/repos/park-bench/confighelper/assignees{/user}","branches_url":"https://api.github.com/repos/park-bench/confighelper/branches{/branch}","tags_url":"https://api.github.com/repos/park-bench/confighelper/tags","blobs_url":"https://api.github.com/repos/park-bench/confighelper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/park-bench/confighelper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/park-bench/confighelper/git/refs{/sha}","trees_url":"https://api.github.com/repos/park-bench/confighelper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/park-bench/confighelper/statuses/{sha}","languages_url":"https://api.github.com/repos/park-bench/confighelper/languages","stargazers_url":"https://api.github.com/repos/park-bench/confighelper/stargazers","contributors_url":"https://api.github.com/repos/park-bench/confighelper/contributors","subscribers_url":"https://api.github.com/repos/park-bench/confighelper/subscribers","subscription_url":"https://api.github.com/repos/park-bench/confighelper/subscription","commits_url":"https://api.github.com/repos/park-bench/confighelper/commits{/sha}","git_commits_url":"https://api.github.com/repos/park-bench/confighelper/git/commits{/sha}","comments_url":"https://api.github.com/repos/park-bench/confighelper/comments{/number}","issue_comment_url":"https://api.github.com/repos/park-bench/confighelper/issues/comments{/number}","contents_url":"https://api.github.com/repos/park-bench/confighelper/contents/{+path}","compare_url":"https://api.github.com/repos/park-bench/confighelper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/park-bench/confighelper/merges","archive_url":"https://api.github.com/repos/park-bench/confighelper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/park-bench/confighelper/downloads","issues_url":"https://api.github.com/repos/park-bench/confighelper/issues{/number}","pulls_url":"https://api.github.com/repos/park-bench/confighelper/pulls{/number}","milestones_url":"https://api.github.com/repos/park-bench/confighelper/milestones{/number}","notifications_url":"https://api.github.com/repos/park-bench/confighelper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/park-bench/confighelper/labels{/name}","releases_url":"https://api.github.com/repos/park-bench/confighelper/releases{/id}","deployments_url":"https://api.github.com/repos/park-bench/confighelper/deployments","created_at":"2015-09-18T00:00:33Z","updated_at":"2018-07-26T03:04:27Z","pushed_at":"2018-10-23T03:03:20Z","git_url":"git://github.com/park-bench/confighelper.git","ssh_url":"git@github.com:park-bench/confighelper.git","clone_url":"https://github.com/park-bench/confighelper.git","svn_url":"https://github.com/park-bench/confighelper","homepage":null,"size":148,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"park-bench:master","ref":"master","sha":"7acdd69d5c7063b17f22c6d8b9266d963ad54249","user":{"login":"park-bench","id":13323173,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMzIzMTcz","avatar_url":"https://avatars0.githubusercontent.com/u/13323173?v=4","gravatar_id":"","url":"https://api.github.com/users/park-bench","html_url":"https://github.com/park-bench","followers_url":"https://api.github.com/users/park-bench/followers","following_url":"https://api.github.com/users/park-bench/following{/other_user}","gists_url":"https://api.github.com/users/park-bench/gists{/gist_id}","starred_url":"https://api.github.com/users/park-bench/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/park-bench/subscriptions","organizations_url":"https://api.github.com/users/park-bench/orgs","repos_url":"https://api.github.com/users/park-bench/repos","events_url":"https://api.github.com/users/park-bench/events{/privacy}","received_events_url":"https://api.github.com/users/park-bench/received_events","type":"Organization","site_admin":false},"repo":{"id":42688971,"node_id":"MDEwOlJlcG9zaXRvcnk0MjY4ODk3MQ==","name":"confighelper","full_name":"park-bench/confighelper","private":false,"owner":{"login":"park-bench","id":13323173,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMzIzMTcz","avatar_url":"https://avatars0.githubusercontent.com/u/13323173?v=4","gravatar_id":"","url":"https://api.github.com/users/park-bench","html_url":"https://github.com/park-bench","followers_url":"https://api.github.com/users/park-bench/followers","following_url":"https://api.github.com/users/park-bench/following{/other_user}","gists_url":"https://api.github.com/users/park-bench/gists{/gist_id}","starred_url":"https://api.github.com/users/park-bench/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/park-bench/subscriptions","organizations_url":"https://api.github.com/users/park-bench/orgs","repos_url":"https://api.github.com/users/park-bench/repos","events_url":"https://api.github.com/users/park-bench/events{/privacy}","received_events_url":"https://api.github.com/users/park-bench/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/park-bench/confighelper","description":"Helps parse Parkbench configuration files.","fork":false,"url":"https://api.github.com/repos/park-bench/confighelper","forks_url":"https://api.github.com/repos/park-bench/confighelper/forks","keys_url":"https://api.github.com/repos/park-bench/confighelper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/park-bench/confighelper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/park-bench/confighelper/teams","hooks_url":"https://api.github.com/repos/park-bench/confighelper/hooks","issue_events_url":"https://api.github.com/repos/park-bench/confighelper/issues/events{/number}","events_url":"https://api.github.com/repos/park-bench/confighelper/events","assignees_url":"https://api.github.com/repos/park-bench/confighelper/assignees{/user}","branches_url":"https://api.github.com/repos/park-bench/confighelper/branches{/branch}","tags_url":"https://api.github.com/repos/park-bench/confighelper/tags","blobs_url":"https://api.github.com/repos/park-bench/confighelper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/park-bench/confighelper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/park-bench/confighelper/git/refs{/sha}","trees_url":"https://api.github.com/repos/park-bench/confighelper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/park-bench/confighelper/statuses/{sha}","languages_url":"https://api.github.com/repos/park-bench/confighelper/languages","stargazers_url":"https://api.github.com/repos/park-bench/confighelper/stargazers","contributors_url":"https://api.github.com/repos/park-bench/confighelper/contributors","subscribers_url":"https://api.github.com/repos/park-bench/confighelper/subscribers","subscription_url":"https://api.github.com/repos/park-bench/confighelper/subscription","commits_url":"https://api.github.com/repos/park-bench/confighelper/commits{/sha}","git_commits_url":"https://api.github.com/repos/park-bench/confighelper/git/commits{/sha}","comments_url":"https://api.github.com/repos/park-bench/confighelper/comments{/number}","issue_comment_url":"https://api.github.com/repos/park-bench/confighelper/issues/comments{/number}","contents_url":"https://api.github.com/repos/park-bench/confighelper/contents/{+path}","compare_url":"https://api.github.com/repos/park-bench/confighelper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/park-bench/confighelper/merges","archive_url":"https://api.github.com/repos/park-bench/confighelper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/park-bench/confighelper/downloads","issues_url":"https://api.github.com/repos/park-bench/confighelper/issues{/number}","pulls_url":"https://api.github.com/repos/park-bench/confighelper/pulls{/number}","milestones_url":"https://api.github.com/repos/park-bench/confighelper/milestones{/number}","notifications_url":"https://api.github.com/repos/park-bench/confighelper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/park-bench/confighelper/labels{/name}","releases_url":"https://api.github.com/repos/park-bench/confighelper/releases{/id}","deployments_url":"https://api.github.com/repos/park-bench/confighelper/deployments","created_at":"2015-09-18T00:00:33Z","updated_at":"2018-07-26T03:04:27Z","pushed_at":"2018-10-23T03:03:20Z","git_url":"git://github.com/park-bench/confighelper.git","ssh_url":"git@github.com:park-bench/confighelper.git","clone_url":"https://github.com/park-bench/confighelper.git","svn_url":"https://github.com/park-bench/confighelper","homepage":null,"size":148,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/park-bench/confighelper/pulls/15"},"html":{"href":"https://github.com/park-bench/confighelper/pull/15"},"issue":{"href":"https://api.github.com/repos/park-bench/confighelper/issues/15"},"comments":{"href":"https://api.github.com/repos/park-bench/confighelper/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/park-bench/confighelper/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/park-bench/confighelper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/park-bench/confighelper/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/park-bench/confighelper/statuses/5f86b62ea928a9d0244b0fbd743dba849a3b050e"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"eviljoel"}}