{"action":"created","comment":{"url":"https://api.github.com/repos/CanalTP/tartare/pulls/comments/88872509","pull_request_review_id":9430659,"id":88872509,"diff_hunk":"@@ -40,38 +41,56 @@\n from tartare import tasks\n \n \n+def add_coverage_data(coverage_id, coverage, environment_type):\n+    if coverage is None:\n+        return {'message': 'bad coverage {}'.format(coverage_id)}, 404\n+\n+    if environment_type not in coverage.environments:\n+        return {'message': 'bad environment {}'.format(environment_type)}, 404\n+\n+    if not request.files :\n+        return {'message': 'no file provided'}, 400\n+    if request.files and 'file' not in request.files:\n+        return {'message': 'file provided with bad param (\"file\" param expected)'}, 400\n+    content = request.files['file']\n+    logger = logging.getLogger(__name__)\n+    logger.info('content received: %s', content)\n+    with tempfile.TemporaryDirectory() as tmpdirname:\n+        tmp_file = os.path.join(tmpdirname, content.filename)\n+        content.save(tmp_file)\n+        #TODO: improve this function so we don't have to write the file localy first\n+        file_type, file_name = data_handler.type_of_data(tmp_file)\n+        if file_type in [None, \"tmp\"] :\n+            logger.warning('invalid file provided: %s', content.filename)\n+            return {'message': 'invalid file provided: {}'.format(content.filename)}, 400\n+        with open(tmp_file, 'rb') as file:\n+            if file_type == 'fusio': #ntfs is called fusio in type_of_data\n+                coverage.save_ntfs(environment_type, file)\n+                tasks.send_ntfs_to_tyr.delay(coverage_id, environment_type)\n+            else:\n+                #we need to temporary save the file before sending it\n+                file_id = models.save_file_in_gridfs(file, filename=content.filename)\n+                tasks.send_file_to_tyr_and_discard.delay(coverage_id, environment_type, file_id)\n+    return {'message': 'Valid {} file provided : {}'.format(file_type, file_name)}, 200\n+\n class DataUpdate(Resource):\n     def post(self, coverage_id, environment_type):\n         coverage = models.Coverage.get(coverage_id)\n+        return add_coverage_data(coverage_id, coverage, environment_type)\n+\n+class CoverageData(Resource):\n+    def post(self, coverage_id, environment_type, data_type=None):\n+        coverage = models.Coverage.get(coverage_id)\n+        return add_coverage_data(coverage, environment_type)\n+\n+    def get(self, coverage_id, environment_type, data_type):\n+        if data_type != 'ntfs':\n+            return {'message': 'bad data type {} (\"ntfs\" expected)'.format(data_type)}, 404","path":"tartare/interfaces/data_update.py","position":56,"original_position":56,"commit_id":"fc252489af6db404fefd52ecec011305be2ea173","original_commit_id":"fc252489af6db404fefd52ecec011305be2ea173","user":{"login":"pbougue","id":12812530,"avatar_url":"https://avatars.githubusercontent.com/u/12812530?v=3","gravatar_id":"","url":"https://api.github.com/users/pbougue","html_url":"https://github.com/pbougue","followers_url":"https://api.github.com/users/pbougue/followers","following_url":"https://api.github.com/users/pbougue/following{/other_user}","gists_url":"https://api.github.com/users/pbougue/gists{/gist_id}","starred_url":"https://api.github.com/users/pbougue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbougue/subscriptions","organizations_url":"https://api.github.com/users/pbougue/orgs","repos_url":"https://api.github.com/users/pbougue/repos","events_url":"https://api.github.com/users/pbougue/events{/privacy}","received_events_url":"https://api.github.com/users/pbougue/received_events","type":"User","site_admin":false},"body":"It would be nicer to have a list and call it both for test and message so everything is updated at the same time","created_at":"2016-11-21T11:06:48Z","updated_at":"2016-11-21T11:11:34Z","html_url":"https://github.com/CanalTP/tartare/pull/65#discussion_r88872509","pull_request_url":"https://api.github.com/repos/CanalTP/tartare/pulls/65","_links":{"self":{"href":"https://api.github.com/repos/CanalTP/tartare/pulls/comments/88872509"},"html":{"href":"https://github.com/CanalTP/tartare/pull/65#discussion_r88872509"},"pull_request":{"href":"https://api.github.com/repos/CanalTP/tartare/pulls/65"}}},"pull_request":{"url":"https://api.github.com/repos/CanalTP/tartare/pulls/65","id":93787424,"html_url":"https://github.com/CanalTP/tartare/pull/65","diff_url":"https://github.com/CanalTP/tartare/pull/65.diff","patch_url":"https://github.com/CanalTP/tartare/pull/65.patch","issue_url":"https://api.github.com/repos/CanalTP/tartare/issues/65","number":65,"state":"open","locked":false,"title":"Adding a NTFS download API to speed-up data analyse","user":{"login":"prhod","id":5628909,"avatar_url":"https://avatars.githubusercontent.com/u/5628909?v=3","gravatar_id":"","url":"https://api.github.com/users/prhod","html_url":"https://github.com/prhod","followers_url":"https://api.github.com/users/prhod/followers","following_url":"https://api.github.com/users/prhod/following{/other_user}","gists_url":"https://api.github.com/users/prhod/gists{/gist_id}","starred_url":"https://api.github.com/users/prhod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prhod/subscriptions","organizations_url":"https://api.github.com/users/prhod/orgs","repos_url":"https://api.github.com/users/prhod/repos","events_url":"https://api.github.com/users/prhod/events{/privacy}","received_events_url":"https://api.github.com/users/prhod/received_events","type":"User","site_admin":false},"body":"There was only a POST API in `/coverages/<string:coverage_id>/environments/<string:environment_type>/data_update` so I added a GET API on the same end_point.","created_at":"2016-11-15T15:31:33Z","updated_at":"2016-11-21T11:11:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e140222a11e591da0dcc7b4d18d7ca5ee0b3520","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CanalTP/tartare/pulls/65/commits","review_comments_url":"https://api.github.com/repos/CanalTP/tartare/pulls/65/comments","review_comment_url":"https://api.github.com/repos/CanalTP/tartare/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CanalTP/tartare/issues/65/comments","statuses_url":"https://api.github.com/repos/CanalTP/tartare/statuses/fc252489af6db404fefd52ecec011305be2ea173","head":{"label":"prhod:ntfs_get","ref":"ntfs_get","sha":"fc252489af6db404fefd52ecec011305be2ea173","user":{"login":"prhod","id":5628909,"avatar_url":"https://avatars.githubusercontent.com/u/5628909?v=3","gravatar_id":"","url":"https://api.github.com/users/prhod","html_url":"https://github.com/prhod","followers_url":"https://api.github.com/users/prhod/followers","following_url":"https://api.github.com/users/prhod/following{/other_user}","gists_url":"https://api.github.com/users/prhod/gists{/gist_id}","starred_url":"https://api.github.com/users/prhod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prhod/subscriptions","organizations_url":"https://api.github.com/users/prhod/orgs","repos_url":"https://api.github.com/users/prhod/repos","events_url":"https://api.github.com/users/prhod/events{/privacy}","received_events_url":"https://api.github.com/users/prhod/received_events","type":"User","site_admin":false},"repo":{"id":63146280,"name":"tartare","full_name":"prhod/tartare","owner":{"login":"prhod","id":5628909,"avatar_url":"https://avatars.githubusercontent.com/u/5628909?v=3","gravatar_id":"","url":"https://api.github.com/users/prhod","html_url":"https://github.com/prhod","followers_url":"https://api.github.com/users/prhod/followers","following_url":"https://api.github.com/users/prhod/following{/other_user}","gists_url":"https://api.github.com/users/prhod/gists{/gist_id}","starred_url":"https://api.github.com/users/prhod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prhod/subscriptions","organizations_url":"https://api.github.com/users/prhod/orgs","repos_url":"https://api.github.com/users/prhod/repos","events_url":"https://api.github.com/users/prhod/events{/privacy}","received_events_url":"https://api.github.com/users/prhod/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/prhod/tartare","description":"data integration","fork":true,"url":"https://api.github.com/repos/prhod/tartare","forks_url":"https://api.github.com/repos/prhod/tartare/forks","keys_url":"https://api.github.com/repos/prhod/tartare/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prhod/tartare/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prhod/tartare/teams","hooks_url":"https://api.github.com/repos/prhod/tartare/hooks","issue_events_url":"https://api.github.com/repos/prhod/tartare/issues/events{/number}","events_url":"https://api.github.com/repos/prhod/tartare/events","assignees_url":"https://api.github.com/repos/prhod/tartare/assignees{/user}","branches_url":"https://api.github.com/repos/prhod/tartare/branches{/branch}","tags_url":"https://api.github.com/repos/prhod/tartare/tags","blobs_url":"https://api.github.com/repos/prhod/tartare/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prhod/tartare/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prhod/tartare/git/refs{/sha}","trees_url":"https://api.github.com/repos/prhod/tartare/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prhod/tartare/statuses/{sha}","languages_url":"https://api.github.com/repos/prhod/tartare/languages","stargazers_url":"https://api.github.com/repos/prhod/tartare/stargazers","contributors_url":"https://api.github.com/repos/prhod/tartare/contributors","subscribers_url":"https://api.github.com/repos/prhod/tartare/subscribers","subscription_url":"https://api.github.com/repos/prhod/tartare/subscription","commits_url":"https://api.github.com/repos/prhod/tartare/commits{/sha}","git_commits_url":"https://api.github.com/repos/prhod/tartare/git/commits{/sha}","comments_url":"https://api.github.com/repos/prhod/tartare/comments{/number}","issue_comment_url":"https://api.github.com/repos/prhod/tartare/issues/comments{/number}","contents_url":"https://api.github.com/repos/prhod/tartare/contents/{+path}","compare_url":"https://api.github.com/repos/prhod/tartare/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prhod/tartare/merges","archive_url":"https://api.github.com/repos/prhod/tartare/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prhod/tartare/downloads","issues_url":"https://api.github.com/repos/prhod/tartare/issues{/number}","pulls_url":"https://api.github.com/repos/prhod/tartare/pulls{/number}","milestones_url":"https://api.github.com/repos/prhod/tartare/milestones{/number}","notifications_url":"https://api.github.com/repos/prhod/tartare/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prhod/tartare/labels{/name}","releases_url":"https://api.github.com/repos/prhod/tartare/releases{/id}","deployments_url":"https://api.github.com/repos/prhod/tartare/deployments","created_at":"2016-07-12T09:44:58Z","updated_at":"2016-07-12T09:44:58Z","pushed_at":"2016-11-21T10:19:06Z","git_url":"git://github.com/prhod/tartare.git","ssh_url":"git@github.com:prhod/tartare.git","clone_url":"https://github.com/prhod/tartare.git","svn_url":"https://github.com/prhod/tartare","homepage":null,"size":266,"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":"CanalTP:master","ref":"master","sha":"80cc1f278b02fe8c3bffeeb6f53675765246dff4","user":{"login":"CanalTP","id":2743985,"avatar_url":"https://avatars.githubusercontent.com/u/2743985?v=3","gravatar_id":"","url":"https://api.github.com/users/CanalTP","html_url":"https://github.com/CanalTP","followers_url":"https://api.github.com/users/CanalTP/followers","following_url":"https://api.github.com/users/CanalTP/following{/other_user}","gists_url":"https://api.github.com/users/CanalTP/gists{/gist_id}","starred_url":"https://api.github.com/users/CanalTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanalTP/subscriptions","organizations_url":"https://api.github.com/users/CanalTP/orgs","repos_url":"https://api.github.com/users/CanalTP/repos","events_url":"https://api.github.com/users/CanalTP/events{/privacy}","received_events_url":"https://api.github.com/users/CanalTP/received_events","type":"Organization","site_admin":false},"repo":{"id":62649486,"name":"tartare","full_name":"CanalTP/tartare","owner":{"login":"CanalTP","id":2743985,"avatar_url":"https://avatars.githubusercontent.com/u/2743985?v=3","gravatar_id":"","url":"https://api.github.com/users/CanalTP","html_url":"https://github.com/CanalTP","followers_url":"https://api.github.com/users/CanalTP/followers","following_url":"https://api.github.com/users/CanalTP/following{/other_user}","gists_url":"https://api.github.com/users/CanalTP/gists{/gist_id}","starred_url":"https://api.github.com/users/CanalTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanalTP/subscriptions","organizations_url":"https://api.github.com/users/CanalTP/orgs","repos_url":"https://api.github.com/users/CanalTP/repos","events_url":"https://api.github.com/users/CanalTP/events{/privacy}","received_events_url":"https://api.github.com/users/CanalTP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CanalTP/tartare","description":"data integration","fork":false,"url":"https://api.github.com/repos/CanalTP/tartare","forks_url":"https://api.github.com/repos/CanalTP/tartare/forks","keys_url":"https://api.github.com/repos/CanalTP/tartare/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CanalTP/tartare/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CanalTP/tartare/teams","hooks_url":"https://api.github.com/repos/CanalTP/tartare/hooks","issue_events_url":"https://api.github.com/repos/CanalTP/tartare/issues/events{/number}","events_url":"https://api.github.com/repos/CanalTP/tartare/events","assignees_url":"https://api.github.com/repos/CanalTP/tartare/assignees{/user}","branches_url":"https://api.github.com/repos/CanalTP/tartare/branches{/branch}","tags_url":"https://api.github.com/repos/CanalTP/tartare/tags","blobs_url":"https://api.github.com/repos/CanalTP/tartare/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CanalTP/tartare/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CanalTP/tartare/git/refs{/sha}","trees_url":"https://api.github.com/repos/CanalTP/tartare/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CanalTP/tartare/statuses/{sha}","languages_url":"https://api.github.com/repos/CanalTP/tartare/languages","stargazers_url":"https://api.github.com/repos/CanalTP/tartare/stargazers","contributors_url":"https://api.github.com/repos/CanalTP/tartare/contributors","subscribers_url":"https://api.github.com/repos/CanalTP/tartare/subscribers","subscription_url":"https://api.github.com/repos/CanalTP/tartare/subscription","commits_url":"https://api.github.com/repos/CanalTP/tartare/commits{/sha}","git_commits_url":"https://api.github.com/repos/CanalTP/tartare/git/commits{/sha}","comments_url":"https://api.github.com/repos/CanalTP/tartare/comments{/number}","issue_comment_url":"https://api.github.com/repos/CanalTP/tartare/issues/comments{/number}","contents_url":"https://api.github.com/repos/CanalTP/tartare/contents/{+path}","compare_url":"https://api.github.com/repos/CanalTP/tartare/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CanalTP/tartare/merges","archive_url":"https://api.github.com/repos/CanalTP/tartare/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CanalTP/tartare/downloads","issues_url":"https://api.github.com/repos/CanalTP/tartare/issues{/number}","pulls_url":"https://api.github.com/repos/CanalTP/tartare/pulls{/number}","milestones_url":"https://api.github.com/repos/CanalTP/tartare/milestones{/number}","notifications_url":"https://api.github.com/repos/CanalTP/tartare/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CanalTP/tartare/labels{/name}","releases_url":"https://api.github.com/repos/CanalTP/tartare/releases{/id}","deployments_url":"https://api.github.com/repos/CanalTP/tartare/deployments","created_at":"2016-07-05T15:47:10Z","updated_at":"2016-07-06T12:14:11Z","pushed_at":"2016-11-21T10:19:07Z","git_url":"git://github.com/CanalTP/tartare.git","ssh_url":"git@github.com:CanalTP/tartare.git","clone_url":"https://github.com/CanalTP/tartare.git","svn_url":"https://github.com/CanalTP/tartare","homepage":null,"size":259,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":7,"forks":9,"open_issues":7,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CanalTP/tartare/pulls/65"},"html":{"href":"https://github.com/CanalTP/tartare/pull/65"},"issue":{"href":"https://api.github.com/repos/CanalTP/tartare/issues/65"},"comments":{"href":"https://api.github.com/repos/CanalTP/tartare/issues/65/comments"},"review_comments":{"href":"https://api.github.com/repos/CanalTP/tartare/pulls/65/comments"},"review_comment":{"href":"https://api.github.com/repos/CanalTP/tartare/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CanalTP/tartare/pulls/65/commits"},"statuses":{"href":"https://api.github.com/repos/CanalTP/tartare/statuses/fc252489af6db404fefd52ecec011305be2ea173"}}}}
{"actor":{"display_login":"pbougue"}}