{"action":"created","comment":{"url":"https://api.github.com/repos/framed-data/mcv/pulls/comments/50632562","id":50632562,"diff_hunk":"@@ -0,0 +1,150 @@\n+\"\"\"Patchwork\"\"\"\n+import os\n+import os.path\n+import json\n+import requests\n+import subprocess\n+\n+from functools import partial\n+\n+PATCHWORK_API_ENDPOINT = os.getenv('PATCHWORK_API_ENDPOINT',\n+                                   \"https://api.patchworksecurity.com/api/v1\")\n+DEFAULT_UUID_PATH = '/etc/patchwork/uuid'\n+DPKG_QUERY_CMD = [\"/usr/bin/dpkg-query\", \"-W\",\n+                  \"-f\", \"${Status}\\t${Package}\\t${Version}\\n\"]\n+\n+\n+def register(api_key, name, uuid_path=DEFAULT_UUID_PATH):\n+    \"\"\"Register this machine\n+\n+    UUID metadata is stored in uuid_path. The machine is only\n+    registered if the UUID metadata isn't found.\n+\n+    Returns:\n+        dict: JSON metadata for this machine\n+    \"\"\"\n+    if os.path.exists(uuid_path):\n+        with open(uuid_path, 'r') as f:\n+            machine_data = json.load(f)\n+\n+        return machine_data\n+\n+    _mkdirs(uuid_path)\n+\n+    os_data = _get_os_info()\n+    os_data.update({'name': name})\n+\n+    url = \"/\".join([\n+        PATCHWORK_API_ENDPOINT,\n+        \"machine\"])\n+\n+    machine_data = _post(api_key=api_key, url=url, data=os_data)\n+    _save_uuid(uuid_path, machine_data)\n+\n+    return machine_data\n+\n+def update(api_key, packages, uuid=None, uuid_path=DEFAULT_UUID_PATH):","path":"mcv/patchwork.py","position":null,"original_position":46,"commit_id":"3f602bdb457619364e82fe1e5c0d4bb6f4943717","original_commit_id":"46a42c117306dd7dd5579f7881128d041dc62c7e","user":{"login":"elliot42","id":127919,"avatar_url":"https://avatars.githubusercontent.com/u/127919?v=3","gravatar_id":"","url":"https://api.github.com/users/elliot42","html_url":"https://github.com/elliot42","followers_url":"https://api.github.com/users/elliot42/followers","following_url":"https://api.github.com/users/elliot42/following{/other_user}","gists_url":"https://api.github.com/users/elliot42/gists{/gist_id}","starred_url":"https://api.github.com/users/elliot42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elliot42/subscriptions","organizations_url":"https://api.github.com/users/elliot42/orgs","repos_url":"https://api.github.com/users/elliot42/repos","events_url":"https://api.github.com/users/elliot42/events{/privacy}","received_events_url":"https://api.github.com/users/elliot42/received_events","type":"User","site_admin":false},"body":"If `packages` needs a specific structure (it looks like it's list of 3-tuples? `[[status, package, version], ...]`) probably worth mentioning in docstring","created_at":"2016-01-24T09:10:37Z","updated_at":"2016-01-24T09:10:37Z","html_url":"https://github.com/framed-data/mcv/pull/101#discussion_r50632562","pull_request_url":"https://api.github.com/repos/framed-data/mcv/pulls/101","_links":{"self":{"href":"https://api.github.com/repos/framed-data/mcv/pulls/comments/50632562"},"html":{"href":"https://github.com/framed-data/mcv/pull/101#discussion_r50632562"},"pull_request":{"href":"https://api.github.com/repos/framed-data/mcv/pulls/101"}}},"pull_request":{"url":"https://api.github.com/repos/framed-data/mcv/pulls/101","id":56829950,"html_url":"https://github.com/framed-data/mcv/pull/101","diff_url":"https://github.com/framed-data/mcv/pull/101.diff","patch_url":"https://github.com/framed-data/mcv/pull/101.patch","issue_url":"https://api.github.com/repos/framed-data/mcv/issues/101","number":101,"state":"open","locked":false,"title":"Feature/iss1 patchwork integration","user":{"login":"dchan","id":403603,"avatar_url":"https://avatars.githubusercontent.com/u/403603?v=3","gravatar_id":"","url":"https://api.github.com/users/dchan","html_url":"https://github.com/dchan","followers_url":"https://api.github.com/users/dchan/followers","following_url":"https://api.github.com/users/dchan/following{/other_user}","gists_url":"https://api.github.com/users/dchan/gists{/gist_id}","starred_url":"https://api.github.com/users/dchan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchan/subscriptions","organizations_url":"https://api.github.com/users/dchan/orgs","repos_url":"https://api.github.com/users/dchan/repos","events_url":"https://api.github.com/users/dchan/events{/privacy}","received_events_url":"https://api.github.com/users/dchan/received_events","type":"User","site_admin":false},"body":"This implements the basic Patchwork API [1] as a mcv module. Tested on python 2.7.6 with supplied requirements.txt\r\n\r\nThere is no support for the GET functionalities in this PR.\r\n\r\n[1] - https://patchworksecurity.com/docs/","created_at":"2016-01-22T00:15:15Z","updated_at":"2016-01-24T09:10:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fcc497905a8efee21338e4cf2ca95d94a0acad78","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/framed-data/mcv/pulls/101/commits","review_comments_url":"https://api.github.com/repos/framed-data/mcv/pulls/101/comments","review_comment_url":"https://api.github.com/repos/framed-data/mcv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framed-data/mcv/issues/101/comments","statuses_url":"https://api.github.com/repos/framed-data/mcv/statuses/3f602bdb457619364e82fe1e5c0d4bb6f4943717","head":{"label":"PatchworkSecurity:feature/iss1_patchwork_integration","ref":"feature/iss1_patchwork_integration","sha":"3f602bdb457619364e82fe1e5c0d4bb6f4943717","user":{"login":"PatchworkSecurity","id":16584923,"avatar_url":"https://avatars.githubusercontent.com/u/16584923?v=3","gravatar_id":"","url":"https://api.github.com/users/PatchworkSecurity","html_url":"https://github.com/PatchworkSecurity","followers_url":"https://api.github.com/users/PatchworkSecurity/followers","following_url":"https://api.github.com/users/PatchworkSecurity/following{/other_user}","gists_url":"https://api.github.com/users/PatchworkSecurity/gists{/gist_id}","starred_url":"https://api.github.com/users/PatchworkSecurity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PatchworkSecurity/subscriptions","organizations_url":"https://api.github.com/users/PatchworkSecurity/orgs","repos_url":"https://api.github.com/users/PatchworkSecurity/repos","events_url":"https://api.github.com/users/PatchworkSecurity/events{/privacy}","received_events_url":"https://api.github.com/users/PatchworkSecurity/received_events","type":"Organization","site_admin":false},"repo":{"id":49911969,"name":"mcv","full_name":"PatchworkSecurity/mcv","owner":{"login":"PatchworkSecurity","id":16584923,"avatar_url":"https://avatars.githubusercontent.com/u/16584923?v=3","gravatar_id":"","url":"https://api.github.com/users/PatchworkSecurity","html_url":"https://github.com/PatchworkSecurity","followers_url":"https://api.github.com/users/PatchworkSecurity/followers","following_url":"https://api.github.com/users/PatchworkSecurity/following{/other_user}","gists_url":"https://api.github.com/users/PatchworkSecurity/gists{/gist_id}","starred_url":"https://api.github.com/users/PatchworkSecurity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PatchworkSecurity/subscriptions","organizations_url":"https://api.github.com/users/PatchworkSecurity/orgs","repos_url":"https://api.github.com/users/PatchworkSecurity/repos","events_url":"https://api.github.com/users/PatchworkSecurity/events{/privacy}","received_events_url":"https://api.github.com/users/PatchworkSecurity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PatchworkSecurity/mcv","description":"Spartan configuration management in Python","fork":true,"url":"https://api.github.com/repos/PatchworkSecurity/mcv","forks_url":"https://api.github.com/repos/PatchworkSecurity/mcv/forks","keys_url":"https://api.github.com/repos/PatchworkSecurity/mcv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PatchworkSecurity/mcv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PatchworkSecurity/mcv/teams","hooks_url":"https://api.github.com/repos/PatchworkSecurity/mcv/hooks","issue_events_url":"https://api.github.com/repos/PatchworkSecurity/mcv/issues/events{/number}","events_url":"https://api.github.com/repos/PatchworkSecurity/mcv/events","assignees_url":"https://api.github.com/repos/PatchworkSecurity/mcv/assignees{/user}","branches_url":"https://api.github.com/repos/PatchworkSecurity/mcv/branches{/branch}","tags_url":"https://api.github.com/repos/PatchworkSecurity/mcv/tags","blobs_url":"https://api.github.com/repos/PatchworkSecurity/mcv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PatchworkSecurity/mcv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PatchworkSecurity/mcv/git/refs{/sha}","trees_url":"https://api.github.com/repos/PatchworkSecurity/mcv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PatchworkSecurity/mcv/statuses/{sha}","languages_url":"https://api.github.com/repos/PatchworkSecurity/mcv/languages","stargazers_url":"https://api.github.com/repos/PatchworkSecurity/mcv/stargazers","contributors_url":"https://api.github.com/repos/PatchworkSecurity/mcv/contributors","subscribers_url":"https://api.github.com/repos/PatchworkSecurity/mcv/subscribers","subscription_url":"https://api.github.com/repos/PatchworkSecurity/mcv/subscription","commits_url":"https://api.github.com/repos/PatchworkSecurity/mcv/commits{/sha}","git_commits_url":"https://api.github.com/repos/PatchworkSecurity/mcv/git/commits{/sha}","comments_url":"https://api.github.com/repos/PatchworkSecurity/mcv/comments{/number}","issue_comment_url":"https://api.github.com/repos/PatchworkSecurity/mcv/issues/comments{/number}","contents_url":"https://api.github.com/repos/PatchworkSecurity/mcv/contents/{+path}","compare_url":"https://api.github.com/repos/PatchworkSecurity/mcv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PatchworkSecurity/mcv/merges","archive_url":"https://api.github.com/repos/PatchworkSecurity/mcv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PatchworkSecurity/mcv/downloads","issues_url":"https://api.github.com/repos/PatchworkSecurity/mcv/issues{/number}","pulls_url":"https://api.github.com/repos/PatchworkSecurity/mcv/pulls{/number}","milestones_url":"https://api.github.com/repos/PatchworkSecurity/mcv/milestones{/number}","notifications_url":"https://api.github.com/repos/PatchworkSecurity/mcv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PatchworkSecurity/mcv/labels{/name}","releases_url":"https://api.github.com/repos/PatchworkSecurity/mcv/releases{/id}","deployments_url":"https://api.github.com/repos/PatchworkSecurity/mcv/deployments","created_at":"2016-01-18T23:21:15Z","updated_at":"2016-01-18T23:21:15Z","pushed_at":"2016-01-24T09:07:15Z","git_url":"git://github.com/PatchworkSecurity/mcv.git","ssh_url":"git@github.com:PatchworkSecurity/mcv.git","clone_url":"https://github.com/PatchworkSecurity/mcv.git","svn_url":"https://github.com/PatchworkSecurity/mcv","homepage":null,"size":122,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"framed-data:master","ref":"master","sha":"a06f8629d6321343991b0f8318ede32c1b7ecdd7","user":{"login":"framed-data","id":4543969,"avatar_url":"https://avatars.githubusercontent.com/u/4543969?v=3","gravatar_id":"","url":"https://api.github.com/users/framed-data","html_url":"https://github.com/framed-data","followers_url":"https://api.github.com/users/framed-data/followers","following_url":"https://api.github.com/users/framed-data/following{/other_user}","gists_url":"https://api.github.com/users/framed-data/gists{/gist_id}","starred_url":"https://api.github.com/users/framed-data/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framed-data/subscriptions","organizations_url":"https://api.github.com/users/framed-data/orgs","repos_url":"https://api.github.com/users/framed-data/repos","events_url":"https://api.github.com/users/framed-data/events{/privacy}","received_events_url":"https://api.github.com/users/framed-data/received_events","type":"Organization","site_admin":false},"repo":{"id":21639250,"name":"mcv","full_name":"framed-data/mcv","owner":{"login":"framed-data","id":4543969,"avatar_url":"https://avatars.githubusercontent.com/u/4543969?v=3","gravatar_id":"","url":"https://api.github.com/users/framed-data","html_url":"https://github.com/framed-data","followers_url":"https://api.github.com/users/framed-data/followers","following_url":"https://api.github.com/users/framed-data/following{/other_user}","gists_url":"https://api.github.com/users/framed-data/gists{/gist_id}","starred_url":"https://api.github.com/users/framed-data/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framed-data/subscriptions","organizations_url":"https://api.github.com/users/framed-data/orgs","repos_url":"https://api.github.com/users/framed-data/repos","events_url":"https://api.github.com/users/framed-data/events{/privacy}","received_events_url":"https://api.github.com/users/framed-data/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framed-data/mcv","description":"Spartan configuration management in Python","fork":false,"url":"https://api.github.com/repos/framed-data/mcv","forks_url":"https://api.github.com/repos/framed-data/mcv/forks","keys_url":"https://api.github.com/repos/framed-data/mcv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framed-data/mcv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framed-data/mcv/teams","hooks_url":"https://api.github.com/repos/framed-data/mcv/hooks","issue_events_url":"https://api.github.com/repos/framed-data/mcv/issues/events{/number}","events_url":"https://api.github.com/repos/framed-data/mcv/events","assignees_url":"https://api.github.com/repos/framed-data/mcv/assignees{/user}","branches_url":"https://api.github.com/repos/framed-data/mcv/branches{/branch}","tags_url":"https://api.github.com/repos/framed-data/mcv/tags","blobs_url":"https://api.github.com/repos/framed-data/mcv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framed-data/mcv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framed-data/mcv/git/refs{/sha}","trees_url":"https://api.github.com/repos/framed-data/mcv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framed-data/mcv/statuses/{sha}","languages_url":"https://api.github.com/repos/framed-data/mcv/languages","stargazers_url":"https://api.github.com/repos/framed-data/mcv/stargazers","contributors_url":"https://api.github.com/repos/framed-data/mcv/contributors","subscribers_url":"https://api.github.com/repos/framed-data/mcv/subscribers","subscription_url":"https://api.github.com/repos/framed-data/mcv/subscription","commits_url":"https://api.github.com/repos/framed-data/mcv/commits{/sha}","git_commits_url":"https://api.github.com/repos/framed-data/mcv/git/commits{/sha}","comments_url":"https://api.github.com/repos/framed-data/mcv/comments{/number}","issue_comment_url":"https://api.github.com/repos/framed-data/mcv/issues/comments{/number}","contents_url":"https://api.github.com/repos/framed-data/mcv/contents/{+path}","compare_url":"https://api.github.com/repos/framed-data/mcv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framed-data/mcv/merges","archive_url":"https://api.github.com/repos/framed-data/mcv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framed-data/mcv/downloads","issues_url":"https://api.github.com/repos/framed-data/mcv/issues{/number}","pulls_url":"https://api.github.com/repos/framed-data/mcv/pulls{/number}","milestones_url":"https://api.github.com/repos/framed-data/mcv/milestones{/number}","notifications_url":"https://api.github.com/repos/framed-data/mcv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framed-data/mcv/labels{/name}","releases_url":"https://api.github.com/repos/framed-data/mcv/releases{/id}","deployments_url":"https://api.github.com/repos/framed-data/mcv/deployments","created_at":"2014-07-09T04:26:34Z","updated_at":"2015-11-05T06:17:29Z","pushed_at":"2016-01-24T09:07:16Z","git_url":"git://github.com/framed-data/mcv.git","ssh_url":"git@github.com:framed-data/mcv.git","clone_url":"https://github.com/framed-data/mcv.git","svn_url":"https://github.com/framed-data/mcv","homepage":null,"size":635,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framed-data/mcv/pulls/101"},"html":{"href":"https://github.com/framed-data/mcv/pull/101"},"issue":{"href":"https://api.github.com/repos/framed-data/mcv/issues/101"},"comments":{"href":"https://api.github.com/repos/framed-data/mcv/issues/101/comments"},"review_comments":{"href":"https://api.github.com/repos/framed-data/mcv/pulls/101/comments"},"review_comment":{"href":"https://api.github.com/repos/framed-data/mcv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framed-data/mcv/pulls/101/commits"},"statuses":{"href":"https://api.github.com/repos/framed-data/mcv/statuses/3f602bdb457619364e82fe1e5c0d4bb6f4943717"}}}}