{"action":"created","comment":{"url":"https://api.github.com/repos/mushorg/tanner/pulls/comments/66926295","id":66926295,"diff_hunk":"@@ -1,54 +1,70 @@\n import aiohttp\n import re\n import asyncio\n+import hashlib\n+import os\n+import json\n \n \n class RfiEmulator:\n+    def __init__(self, root_dir):\n+        self.script_dir = root_dir + '/data/scripts'\n+\n     @asyncio.coroutine\n     def download_file(self, path):\n         loop = asyncio.get_event_loop()\n-        session = aiohttp.ClientSession(loop=loop)\n         data = None\n+        filename = None\n         url_pattern = re.compile('.*=(.*(http(s){0,1}|ftp(s){0,1}):.*)')\n         url = url_pattern.match(path).group(1)\n \n+        if not os.path.exists(self.script_dir):\n+            os.makedirs(self.script_dir)\n+\n         if not (url.startswith(\"http\") or url.startswith(\"ftp\")):\n-            yield None\n+            return None\n \n-        try:\n+        with aiohttp.ClientSession(loop=loop) as session:\n             resp = yield from session.get(url)\n-            data = yield from resp.text()\n-\n-        except aiohttp.errors.ClientOSError as e:\n-            print('bad eternal link %s: %s' % (url, e))\n-        else:\n-            yield from resp.release()\n-        finally:\n-            session.close()\n-            return data\n+            try:\n+                data = yield from resp.text()\n+            except Exception as e:\n+                print('Error with response %s' % e)\n+            else:\n+                filename = hashlib.md5(data.encode('utf-8')).hexdigest()\n+                with open(self.script_dir + filename, 'w') as rfile:\n+                    rfile.write(data)\n+            finally:\n+                yield from resp.release()\n+                return filename\n \n     @asyncio.coroutine\n-    def get_rfi_result(self, script):\n+    def get_rfi_result(self, file):","path":"rfi_emulator.py","position":55,"original_position":55,"commit_id":"1dbd257caa14f2d905e9136f3d4b5de533e3a56d","original_commit_id":"1dbd257caa14f2d905e9136f3d4b5de533e3a56d","user":{"login":"glaslos","id":716339,"avatar_url":"https://avatars.githubusercontent.com/u/716339?v=3","gravatar_id":"","url":"https://api.github.com/users/glaslos","html_url":"https://github.com/glaslos","followers_url":"https://api.github.com/users/glaslos/followers","following_url":"https://api.github.com/users/glaslos/following{/other_user}","gists_url":"https://api.github.com/users/glaslos/gists{/gist_id}","starred_url":"https://api.github.com/users/glaslos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glaslos/subscriptions","organizations_url":"https://api.github.com/users/glaslos/orgs","repos_url":"https://api.github.com/users/glaslos/repos","events_url":"https://api.github.com/users/glaslos/events{/privacy}","received_events_url":"https://api.github.com/users/glaslos/received_events","type":"User","site_admin":false},"body":"`file` shadows the build in `file` method","created_at":"2016-06-14T08:16:06Z","updated_at":"2016-06-14T08:16:06Z","html_url":"https://github.com/mushorg/tanner/pull/35#discussion_r66926295","pull_request_url":"https://api.github.com/repos/mushorg/tanner/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/mushorg/tanner/pulls/comments/66926295"},"html":{"href":"https://github.com/mushorg/tanner/pull/35#discussion_r66926295"},"pull_request":{"href":"https://api.github.com/repos/mushorg/tanner/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/mushorg/tanner/pulls/35","id":73512303,"html_url":"https://github.com/mushorg/tanner/pull/35","diff_url":"https://github.com/mushorg/tanner/pull/35.diff","patch_url":"https://github.com/mushorg/tanner/pull/35.patch","issue_url":"https://api.github.com/repos/mushorg/tanner/issues/35","number":35,"state":"open","locked":false,"title":"Feature/rfi improvements","user":{"login":"afeena","id":8390928,"avatar_url":"https://avatars.githubusercontent.com/u/8390928?v=3","gravatar_id":"","url":"https://api.github.com/users/afeena","html_url":"https://github.com/afeena","followers_url":"https://api.github.com/users/afeena/followers","following_url":"https://api.github.com/users/afeena/following{/other_user}","gists_url":"https://api.github.com/users/afeena/gists{/gist_id}","starred_url":"https://api.github.com/users/afeena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afeena/subscriptions","organizations_url":"https://api.github.com/users/afeena/orgs","repos_url":"https://api.github.com/users/afeena/repos","events_url":"https://api.github.com/users/afeena/events{/privacy}","received_events_url":"https://api.github.com/users/afeena/received_events","type":"User","site_admin":false},"body":"Store scripts as a files, return to the SNARE only stdout","created_at":"2016-06-13T00:32:44Z","updated_at":"2016-06-14T08:16:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"527c40205ebc526a0ca448c3035ca56781bdae5b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mushorg/tanner/pulls/35/commits","review_comments_url":"https://api.github.com/repos/mushorg/tanner/pulls/35/comments","review_comment_url":"https://api.github.com/repos/mushorg/tanner/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mushorg/tanner/issues/35/comments","statuses_url":"https://api.github.com/repos/mushorg/tanner/statuses/1dbd257caa14f2d905e9136f3d4b5de533e3a56d","head":{"label":"afeena:feature/rfi-improvements","ref":"feature/rfi-improvements","sha":"1dbd257caa14f2d905e9136f3d4b5de533e3a56d","user":{"login":"afeena","id":8390928,"avatar_url":"https://avatars.githubusercontent.com/u/8390928?v=3","gravatar_id":"","url":"https://api.github.com/users/afeena","html_url":"https://github.com/afeena","followers_url":"https://api.github.com/users/afeena/followers","following_url":"https://api.github.com/users/afeena/following{/other_user}","gists_url":"https://api.github.com/users/afeena/gists{/gist_id}","starred_url":"https://api.github.com/users/afeena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afeena/subscriptions","organizations_url":"https://api.github.com/users/afeena/orgs","repos_url":"https://api.github.com/users/afeena/repos","events_url":"https://api.github.com/users/afeena/events{/privacy}","received_events_url":"https://api.github.com/users/afeena/received_events","type":"User","site_admin":false},"repo":{"id":56975208,"name":"tanner","full_name":"afeena/tanner","owner":{"login":"afeena","id":8390928,"avatar_url":"https://avatars.githubusercontent.com/u/8390928?v=3","gravatar_id":"","url":"https://api.github.com/users/afeena","html_url":"https://github.com/afeena","followers_url":"https://api.github.com/users/afeena/followers","following_url":"https://api.github.com/users/afeena/following{/other_user}","gists_url":"https://api.github.com/users/afeena/gists{/gist_id}","starred_url":"https://api.github.com/users/afeena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afeena/subscriptions","organizations_url":"https://api.github.com/users/afeena/orgs","repos_url":"https://api.github.com/users/afeena/repos","events_url":"https://api.github.com/users/afeena/events{/privacy}","received_events_url":"https://api.github.com/users/afeena/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/afeena/tanner","description":"He who flays the hide","fork":true,"url":"https://api.github.com/repos/afeena/tanner","forks_url":"https://api.github.com/repos/afeena/tanner/forks","keys_url":"https://api.github.com/repos/afeena/tanner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/afeena/tanner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/afeena/tanner/teams","hooks_url":"https://api.github.com/repos/afeena/tanner/hooks","issue_events_url":"https://api.github.com/repos/afeena/tanner/issues/events{/number}","events_url":"https://api.github.com/repos/afeena/tanner/events","assignees_url":"https://api.github.com/repos/afeena/tanner/assignees{/user}","branches_url":"https://api.github.com/repos/afeena/tanner/branches{/branch}","tags_url":"https://api.github.com/repos/afeena/tanner/tags","blobs_url":"https://api.github.com/repos/afeena/tanner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/afeena/tanner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/afeena/tanner/git/refs{/sha}","trees_url":"https://api.github.com/repos/afeena/tanner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/afeena/tanner/statuses/{sha}","languages_url":"https://api.github.com/repos/afeena/tanner/languages","stargazers_url":"https://api.github.com/repos/afeena/tanner/stargazers","contributors_url":"https://api.github.com/repos/afeena/tanner/contributors","subscribers_url":"https://api.github.com/repos/afeena/tanner/subscribers","subscription_url":"https://api.github.com/repos/afeena/tanner/subscription","commits_url":"https://api.github.com/repos/afeena/tanner/commits{/sha}","git_commits_url":"https://api.github.com/repos/afeena/tanner/git/commits{/sha}","comments_url":"https://api.github.com/repos/afeena/tanner/comments{/number}","issue_comment_url":"https://api.github.com/repos/afeena/tanner/issues/comments{/number}","contents_url":"https://api.github.com/repos/afeena/tanner/contents/{+path}","compare_url":"https://api.github.com/repos/afeena/tanner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/afeena/tanner/merges","archive_url":"https://api.github.com/repos/afeena/tanner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/afeena/tanner/downloads","issues_url":"https://api.github.com/repos/afeena/tanner/issues{/number}","pulls_url":"https://api.github.com/repos/afeena/tanner/pulls{/number}","milestones_url":"https://api.github.com/repos/afeena/tanner/milestones{/number}","notifications_url":"https://api.github.com/repos/afeena/tanner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/afeena/tanner/labels{/name}","releases_url":"https://api.github.com/repos/afeena/tanner/releases{/id}","deployments_url":"https://api.github.com/repos/afeena/tanner/deployments","created_at":"2016-04-24T14:14:01Z","updated_at":"2016-04-24T14:14:01Z","pushed_at":"2016-06-13T21:31:48Z","git_url":"git://github.com/afeena/tanner.git","ssh_url":"git@github.com:afeena/tanner.git","clone_url":"https://github.com/afeena/tanner.git","svn_url":"https://github.com/afeena/tanner","homepage":null,"size":74,"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":"mushorg:master","ref":"master","sha":"f2750987ee422ed5c5d8211ce681658d119d03eb","user":{"login":"mushorg","id":2742625,"avatar_url":"https://avatars.githubusercontent.com/u/2742625?v=3","gravatar_id":"","url":"https://api.github.com/users/mushorg","html_url":"https://github.com/mushorg","followers_url":"https://api.github.com/users/mushorg/followers","following_url":"https://api.github.com/users/mushorg/following{/other_user}","gists_url":"https://api.github.com/users/mushorg/gists{/gist_id}","starred_url":"https://api.github.com/users/mushorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mushorg/subscriptions","organizations_url":"https://api.github.com/users/mushorg/orgs","repos_url":"https://api.github.com/users/mushorg/repos","events_url":"https://api.github.com/users/mushorg/events{/privacy}","received_events_url":"https://api.github.com/users/mushorg/received_events","type":"Organization","site_admin":false},"repo":{"id":40407153,"name":"tanner","full_name":"mushorg/tanner","owner":{"login":"mushorg","id":2742625,"avatar_url":"https://avatars.githubusercontent.com/u/2742625?v=3","gravatar_id":"","url":"https://api.github.com/users/mushorg","html_url":"https://github.com/mushorg","followers_url":"https://api.github.com/users/mushorg/followers","following_url":"https://api.github.com/users/mushorg/following{/other_user}","gists_url":"https://api.github.com/users/mushorg/gists{/gist_id}","starred_url":"https://api.github.com/users/mushorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mushorg/subscriptions","organizations_url":"https://api.github.com/users/mushorg/orgs","repos_url":"https://api.github.com/users/mushorg/repos","events_url":"https://api.github.com/users/mushorg/events{/privacy}","received_events_url":"https://api.github.com/users/mushorg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mushorg/tanner","description":"He who flays the hide","fork":false,"url":"https://api.github.com/repos/mushorg/tanner","forks_url":"https://api.github.com/repos/mushorg/tanner/forks","keys_url":"https://api.github.com/repos/mushorg/tanner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mushorg/tanner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mushorg/tanner/teams","hooks_url":"https://api.github.com/repos/mushorg/tanner/hooks","issue_events_url":"https://api.github.com/repos/mushorg/tanner/issues/events{/number}","events_url":"https://api.github.com/repos/mushorg/tanner/events","assignees_url":"https://api.github.com/repos/mushorg/tanner/assignees{/user}","branches_url":"https://api.github.com/repos/mushorg/tanner/branches{/branch}","tags_url":"https://api.github.com/repos/mushorg/tanner/tags","blobs_url":"https://api.github.com/repos/mushorg/tanner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mushorg/tanner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mushorg/tanner/git/refs{/sha}","trees_url":"https://api.github.com/repos/mushorg/tanner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mushorg/tanner/statuses/{sha}","languages_url":"https://api.github.com/repos/mushorg/tanner/languages","stargazers_url":"https://api.github.com/repos/mushorg/tanner/stargazers","contributors_url":"https://api.github.com/repos/mushorg/tanner/contributors","subscribers_url":"https://api.github.com/repos/mushorg/tanner/subscribers","subscription_url":"https://api.github.com/repos/mushorg/tanner/subscription","commits_url":"https://api.github.com/repos/mushorg/tanner/commits{/sha}","git_commits_url":"https://api.github.com/repos/mushorg/tanner/git/commits{/sha}","comments_url":"https://api.github.com/repos/mushorg/tanner/comments{/number}","issue_comment_url":"https://api.github.com/repos/mushorg/tanner/issues/comments{/number}","contents_url":"https://api.github.com/repos/mushorg/tanner/contents/{+path}","compare_url":"https://api.github.com/repos/mushorg/tanner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mushorg/tanner/merges","archive_url":"https://api.github.com/repos/mushorg/tanner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mushorg/tanner/downloads","issues_url":"https://api.github.com/repos/mushorg/tanner/issues{/number}","pulls_url":"https://api.github.com/repos/mushorg/tanner/pulls{/number}","milestones_url":"https://api.github.com/repos/mushorg/tanner/milestones{/number}","notifications_url":"https://api.github.com/repos/mushorg/tanner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mushorg/tanner/labels{/name}","releases_url":"https://api.github.com/repos/mushorg/tanner/releases{/id}","deployments_url":"https://api.github.com/repos/mushorg/tanner/deployments","created_at":"2015-08-08T15:28:24Z","updated_at":"2016-05-09T20:12:54Z","pushed_at":"2016-06-13T21:39:32Z","git_url":"git://github.com/mushorg/tanner.git","ssh_url":"git@github.com:mushorg/tanner.git","clone_url":"https://github.com/mushorg/tanner.git","svn_url":"https://github.com/mushorg/tanner","homepage":null,"size":90,"stargazers_count":9,"watchers_count":9,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":16,"forks":3,"open_issues":16,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mushorg/tanner/pulls/35"},"html":{"href":"https://github.com/mushorg/tanner/pull/35"},"issue":{"href":"https://api.github.com/repos/mushorg/tanner/issues/35"},"comments":{"href":"https://api.github.com/repos/mushorg/tanner/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/mushorg/tanner/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/mushorg/tanner/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mushorg/tanner/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/mushorg/tanner/statuses/1dbd257caa14f2d905e9136f3d4b5de533e3a56d"}}}}
{"actor":{"display_login":"glaslos"}}