{"action":"created","comment":{"url":"https://api.github.com/repos/snowplow/release-manager/pulls/comments/89998562","pull_request_review_id":10523503,"id":89998562,"diff_hunk":"@@ -0,0 +1,75 @@\n+\"\"\"\n+    awss3.py\n+\n+    Copyright (c) 2016 Snowplow Analytics Ltd. All rights reserved.\n+\n+    This program is licensed to you under the Apache License Version 2.0,\n+    and you may not use this file except in compliance with the Apache License\n+    Version 2.0. You may obtain a copy of the Apache License Version 2.0 at\n+    http://www.apache.org/licenses/LICENSE-2.0.\n+\n+    Unless required by applicable law or agreed to in writing,\n+    software distributed under the Apache License Version 2.0 is distributed on\n+    an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n+    express or implied. See the Apache License Version 2.0 for the specific\n+    language governing permissions and limitations there under.\n+\n+    Authors: Joshua Beemster\n+    Copyright: Copyright (c) 2016 Snowplow Analytics Ltd\n+    License: Apache License Version 2.0\n+\"\"\"\n+\n+\n+from __future__ import division\n+\n+import tempfile\n+\n+import boto3\n+from boto3.s3.transfer import S3Transfer\n+from botocore.exceptions import ClientError\n+\n+import release_manager.package as pack\n+\n+\n+def upload_to_s3(args, local, package, target):\n+    \"\"\"Upload artifact to AWS S3\"\"\"\n+\n+    if args.make_artifact:\n+\n+        # Run build commands\n+        if \"build_commands\" in package.keys():\n+            pack.execute_commands(package[\"build_commands\"])\n+\n+        for artifact in package[\"artifacts\"]:\n+            artifact_file = pack.create_artifact(\n+                local['root_dir'],\n+                package['version'],\n+                package['name'],\n+                artifact['type'],\n+                artifact['prefix'],\n+                artifact['suffix'],\n+                artifact['binary_paths']\n+            )\n+\n+            if package['path'].endswith('/'):\n+                path = package['path']\n+            elif not package:\n+                path = ''\n+            else:\n+                path = package['path'] + '/'\n+            full_s3_path = path + artifact_file['artifact_name']\n+\n+            client = boto3.client('s3', 'us-west-2', aws_access_key_id=target['user'], aws_secret_access_key=target['password'])\n+            transfer = S3Transfer(client)\n+            if package['override']:\n+                transfer.upload_file(artifact_file['artifact_path'], package['bucket'], full_s3_path)\n+            else:\n+                try:\n+                    transfer.download_file(package['bucket'], full_s3_path, tempfile.mktemp())\n+                    raise ValueError(\"Artifact at %s already exists\" % (full_s3_path,))","path":"release_manager/targets/awss3.py","position":69,"original_position":69,"commit_id":"708c7bb418453ddc2185711154bd693b5d4f90f2","original_commit_id":"708c7bb418453ddc2185711154bd693b5d4f90f2","user":{"login":"chuwy","id":681171,"avatar_url":"https://avatars.githubusercontent.com/u/681171?v=3","gravatar_id":"","url":"https://api.github.com/users/chuwy","html_url":"https://github.com/chuwy","followers_url":"https://api.github.com/users/chuwy/followers","following_url":"https://api.github.com/users/chuwy/following{/other_user}","gists_url":"https://api.github.com/users/chuwy/gists{/gist_id}","starred_url":"https://api.github.com/users/chuwy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuwy/subscriptions","organizations_url":"https://api.github.com/users/chuwy/orgs","repos_url":"https://api.github.com/users/chuwy/repos","events_url":"https://api.github.com/users/chuwy/events{/privacy}","received_events_url":"https://api.github.com/users/chuwy/received_events","type":"User","site_admin":false},"body":"Ok. Makes sense.","created_at":"2016-11-29T12:24:44Z","updated_at":"2016-11-29T12:24:44Z","html_url":"https://github.com/snowplow/release-manager/pull/20#discussion_r89998562","pull_request_url":"https://api.github.com/repos/snowplow/release-manager/pulls/20","_links":{"self":{"href":"https://api.github.com/repos/snowplow/release-manager/pulls/comments/89998562"},"html":{"href":"https://github.com/snowplow/release-manager/pull/20#discussion_r89998562"},"pull_request":{"href":"https://api.github.com/repos/snowplow/release-manager/pulls/20"}}},"pull_request":{"url":"https://api.github.com/repos/snowplow/release-manager/pulls/20","id":95673291,"html_url":"https://github.com/snowplow/release-manager/pull/20","diff_url":"https://github.com/snowplow/release-manager/pull/20.diff","patch_url":"https://github.com/snowplow/release-manager/pull/20.patch","issue_url":"https://api.github.com/repos/snowplow/release-manager/issues/20","number":20,"state":"open","locked":false,"title":"Release/0.2.0","user":{"login":"chuwy","id":681171,"avatar_url":"https://avatars.githubusercontent.com/u/681171?v=3","gravatar_id":"","url":"https://api.github.com/users/chuwy","html_url":"https://github.com/chuwy","followers_url":"https://api.github.com/users/chuwy/followers","following_url":"https://api.github.com/users/chuwy/following{/other_user}","gists_url":"https://api.github.com/users/chuwy/gists{/gist_id}","starred_url":"https://api.github.com/users/chuwy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuwy/subscriptions","organizations_url":"https://api.github.com/users/chuwy/orgs","repos_url":"https://api.github.com/users/chuwy/repos","events_url":"https://api.github.com/users/chuwy/events{/privacy}","received_events_url":"https://api.github.com/users/chuwy/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-29T11:24:15Z","updated_at":"2016-11-29T12:24:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d7b72b4f29e17be31a2b5ebed169ee90f3393bb7","assignee":{"login":"jbeemster","id":7984544,"avatar_url":"https://avatars.githubusercontent.com/u/7984544?v=3","gravatar_id":"","url":"https://api.github.com/users/jbeemster","html_url":"https://github.com/jbeemster","followers_url":"https://api.github.com/users/jbeemster/followers","following_url":"https://api.github.com/users/jbeemster/following{/other_user}","gists_url":"https://api.github.com/users/jbeemster/gists{/gist_id}","starred_url":"https://api.github.com/users/jbeemster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbeemster/subscriptions","organizations_url":"https://api.github.com/users/jbeemster/orgs","repos_url":"https://api.github.com/users/jbeemster/repos","events_url":"https://api.github.com/users/jbeemster/events{/privacy}","received_events_url":"https://api.github.com/users/jbeemster/received_events","type":"User","site_admin":false},"assignees":[{"login":"jbeemster","id":7984544,"avatar_url":"https://avatars.githubusercontent.com/u/7984544?v=3","gravatar_id":"","url":"https://api.github.com/users/jbeemster","html_url":"https://github.com/jbeemster","followers_url":"https://api.github.com/users/jbeemster/followers","following_url":"https://api.github.com/users/jbeemster/following{/other_user}","gists_url":"https://api.github.com/users/jbeemster/gists{/gist_id}","starred_url":"https://api.github.com/users/jbeemster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbeemster/subscriptions","organizations_url":"https://api.github.com/users/jbeemster/orgs","repos_url":"https://api.github.com/users/jbeemster/repos","events_url":"https://api.github.com/users/jbeemster/events{/privacy}","received_events_url":"https://api.github.com/users/jbeemster/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/snowplow/release-manager/pulls/20/commits","review_comments_url":"https://api.github.com/repos/snowplow/release-manager/pulls/20/comments","review_comment_url":"https://api.github.com/repos/snowplow/release-manager/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snowplow/release-manager/issues/20/comments","statuses_url":"https://api.github.com/repos/snowplow/release-manager/statuses/708c7bb418453ddc2185711154bd693b5d4f90f2","head":{"label":"snowplow:release/0.2.0","ref":"release/0.2.0","sha":"708c7bb418453ddc2185711154bd693b5d4f90f2","user":{"login":"snowplow","id":1476001,"avatar_url":"https://avatars.githubusercontent.com/u/1476001?v=3","gravatar_id":"","url":"https://api.github.com/users/snowplow","html_url":"https://github.com/snowplow","followers_url":"https://api.github.com/users/snowplow/followers","following_url":"https://api.github.com/users/snowplow/following{/other_user}","gists_url":"https://api.github.com/users/snowplow/gists{/gist_id}","starred_url":"https://api.github.com/users/snowplow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowplow/subscriptions","organizations_url":"https://api.github.com/users/snowplow/orgs","repos_url":"https://api.github.com/users/snowplow/repos","events_url":"https://api.github.com/users/snowplow/events{/privacy}","received_events_url":"https://api.github.com/users/snowplow/received_events","type":"Organization","site_admin":false},"repo":{"id":68016406,"name":"release-manager","full_name":"snowplow/release-manager","owner":{"login":"snowplow","id":1476001,"avatar_url":"https://avatars.githubusercontent.com/u/1476001?v=3","gravatar_id":"","url":"https://api.github.com/users/snowplow","html_url":"https://github.com/snowplow","followers_url":"https://api.github.com/users/snowplow/followers","following_url":"https://api.github.com/users/snowplow/following{/other_user}","gists_url":"https://api.github.com/users/snowplow/gists{/gist_id}","starred_url":"https://api.github.com/users/snowplow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowplow/subscriptions","organizations_url":"https://api.github.com/users/snowplow/orgs","repos_url":"https://api.github.com/users/snowplow/repos","events_url":"https://api.github.com/users/snowplow/events{/privacy}","received_events_url":"https://api.github.com/users/snowplow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snowplow/release-manager","description":"Uploads zipfiles to Bintray and creates versions","fork":false,"url":"https://api.github.com/repos/snowplow/release-manager","forks_url":"https://api.github.com/repos/snowplow/release-manager/forks","keys_url":"https://api.github.com/repos/snowplow/release-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snowplow/release-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snowplow/release-manager/teams","hooks_url":"https://api.github.com/repos/snowplow/release-manager/hooks","issue_events_url":"https://api.github.com/repos/snowplow/release-manager/issues/events{/number}","events_url":"https://api.github.com/repos/snowplow/release-manager/events","assignees_url":"https://api.github.com/repos/snowplow/release-manager/assignees{/user}","branches_url":"https://api.github.com/repos/snowplow/release-manager/branches{/branch}","tags_url":"https://api.github.com/repos/snowplow/release-manager/tags","blobs_url":"https://api.github.com/repos/snowplow/release-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snowplow/release-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snowplow/release-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/snowplow/release-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snowplow/release-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/snowplow/release-manager/languages","stargazers_url":"https://api.github.com/repos/snowplow/release-manager/stargazers","contributors_url":"https://api.github.com/repos/snowplow/release-manager/contributors","subscribers_url":"https://api.github.com/repos/snowplow/release-manager/subscribers","subscription_url":"https://api.github.com/repos/snowplow/release-manager/subscription","commits_url":"https://api.github.com/repos/snowplow/release-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/snowplow/release-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/snowplow/release-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/snowplow/release-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/snowplow/release-manager/contents/{+path}","compare_url":"https://api.github.com/repos/snowplow/release-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snowplow/release-manager/merges","archive_url":"https://api.github.com/repos/snowplow/release-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snowplow/release-manager/downloads","issues_url":"https://api.github.com/repos/snowplow/release-manager/issues{/number}","pulls_url":"https://api.github.com/repos/snowplow/release-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/snowplow/release-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/snowplow/release-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snowplow/release-manager/labels{/name}","releases_url":"https://api.github.com/repos/snowplow/release-manager/releases{/id}","deployments_url":"https://api.github.com/repos/snowplow/release-manager/deployments","created_at":"2016-09-12T14:26:13Z","updated_at":"2016-09-16T23:27:11Z","pushed_at":"2016-11-29T11:24:16Z","git_url":"git://github.com/snowplow/release-manager.git","ssh_url":"git@github.com:snowplow/release-manager.git","clone_url":"https://github.com/snowplow/release-manager.git","svn_url":"https://github.com/snowplow/release-manager","homepage":null,"size":24,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":9,"forks":0,"open_issues":9,"watchers":2,"default_branch":"master"}},"base":{"label":"snowplow:master","ref":"master","sha":"05092d64e4c43ffb6cbf2fa3c9c303f455ba576a","user":{"login":"snowplow","id":1476001,"avatar_url":"https://avatars.githubusercontent.com/u/1476001?v=3","gravatar_id":"","url":"https://api.github.com/users/snowplow","html_url":"https://github.com/snowplow","followers_url":"https://api.github.com/users/snowplow/followers","following_url":"https://api.github.com/users/snowplow/following{/other_user}","gists_url":"https://api.github.com/users/snowplow/gists{/gist_id}","starred_url":"https://api.github.com/users/snowplow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowplow/subscriptions","organizations_url":"https://api.github.com/users/snowplow/orgs","repos_url":"https://api.github.com/users/snowplow/repos","events_url":"https://api.github.com/users/snowplow/events{/privacy}","received_events_url":"https://api.github.com/users/snowplow/received_events","type":"Organization","site_admin":false},"repo":{"id":68016406,"name":"release-manager","full_name":"snowplow/release-manager","owner":{"login":"snowplow","id":1476001,"avatar_url":"https://avatars.githubusercontent.com/u/1476001?v=3","gravatar_id":"","url":"https://api.github.com/users/snowplow","html_url":"https://github.com/snowplow","followers_url":"https://api.github.com/users/snowplow/followers","following_url":"https://api.github.com/users/snowplow/following{/other_user}","gists_url":"https://api.github.com/users/snowplow/gists{/gist_id}","starred_url":"https://api.github.com/users/snowplow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowplow/subscriptions","organizations_url":"https://api.github.com/users/snowplow/orgs","repos_url":"https://api.github.com/users/snowplow/repos","events_url":"https://api.github.com/users/snowplow/events{/privacy}","received_events_url":"https://api.github.com/users/snowplow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snowplow/release-manager","description":"Uploads zipfiles to Bintray and creates versions","fork":false,"url":"https://api.github.com/repos/snowplow/release-manager","forks_url":"https://api.github.com/repos/snowplow/release-manager/forks","keys_url":"https://api.github.com/repos/snowplow/release-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snowplow/release-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snowplow/release-manager/teams","hooks_url":"https://api.github.com/repos/snowplow/release-manager/hooks","issue_events_url":"https://api.github.com/repos/snowplow/release-manager/issues/events{/number}","events_url":"https://api.github.com/repos/snowplow/release-manager/events","assignees_url":"https://api.github.com/repos/snowplow/release-manager/assignees{/user}","branches_url":"https://api.github.com/repos/snowplow/release-manager/branches{/branch}","tags_url":"https://api.github.com/repos/snowplow/release-manager/tags","blobs_url":"https://api.github.com/repos/snowplow/release-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snowplow/release-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snowplow/release-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/snowplow/release-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snowplow/release-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/snowplow/release-manager/languages","stargazers_url":"https://api.github.com/repos/snowplow/release-manager/stargazers","contributors_url":"https://api.github.com/repos/snowplow/release-manager/contributors","subscribers_url":"https://api.github.com/repos/snowplow/release-manager/subscribers","subscription_url":"https://api.github.com/repos/snowplow/release-manager/subscription","commits_url":"https://api.github.com/repos/snowplow/release-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/snowplow/release-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/snowplow/release-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/snowplow/release-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/snowplow/release-manager/contents/{+path}","compare_url":"https://api.github.com/repos/snowplow/release-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snowplow/release-manager/merges","archive_url":"https://api.github.com/repos/snowplow/release-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snowplow/release-manager/downloads","issues_url":"https://api.github.com/repos/snowplow/release-manager/issues{/number}","pulls_url":"https://api.github.com/repos/snowplow/release-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/snowplow/release-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/snowplow/release-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snowplow/release-manager/labels{/name}","releases_url":"https://api.github.com/repos/snowplow/release-manager/releases{/id}","deployments_url":"https://api.github.com/repos/snowplow/release-manager/deployments","created_at":"2016-09-12T14:26:13Z","updated_at":"2016-09-16T23:27:11Z","pushed_at":"2016-11-29T11:24:16Z","git_url":"git://github.com/snowplow/release-manager.git","ssh_url":"git@github.com:snowplow/release-manager.git","clone_url":"https://github.com/snowplow/release-manager.git","svn_url":"https://github.com/snowplow/release-manager","homepage":null,"size":24,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":9,"forks":0,"open_issues":9,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snowplow/release-manager/pulls/20"},"html":{"href":"https://github.com/snowplow/release-manager/pull/20"},"issue":{"href":"https://api.github.com/repos/snowplow/release-manager/issues/20"},"comments":{"href":"https://api.github.com/repos/snowplow/release-manager/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/snowplow/release-manager/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/snowplow/release-manager/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snowplow/release-manager/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/snowplow/release-manager/statuses/708c7bb418453ddc2185711154bd693b5d4f90f2"}}}}
{"actor":{"display_login":"chuwy"}}