{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-airflow/pulls/comments/62362097","id":62362097,"diff_hunk":"@@ -0,0 +1,181 @@\n+# -*- coding: utf-8 -*-\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+# http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+#\n+import logging\n+from csv import DictReader\n+from datetime import datetime\n+from tempfile import NamedTemporaryFile\n+\n+from airflow.exceptions import AirflowException\n+from airflow.hooks.base_hook import BaseHook\n+from airflow.utils.file import TemporaryDirectory\n+from airflow.utils.helpers import popen_and_tail\n+\n+\n+class HDFSCliHook(BaseHook):\n+    '''\n+    HDFSCliHook is a wrap around \"hadoop fs\" cli tool\n+    '''\n+    def __init__(self, hdfs_cli_conn_id='hdfs_cli_default'):\n+        self.hdfs_cli_conn_id = hdfs_cli_conn_id\n+        self.conn = self.get_connection(hdfs_cli_conn_id)\n+        self.binary = self.conn.extra_dejson.get('binary', 'hadoop fs').split(' ')\n+        self.fallback_conn_id = \\\n+            self.conn.extra_dejson.get('fallback_conn_id', 'hdfs_default')\n+\n+    def run_cli(self, arguments, verbose=True):\n+        hdfs_cmd = self.binary + arguments\n+        logging.info('HDFS command \"%s\"', ' '.join(hdfs_cmd))\n+        self.sp, tail = popen_and_tail(hdfs_cmd, shell=True)","path":"airflow/contrib/hooks/hdfs_cli_hook.py","position":40,"original_position":40,"commit_id":"8f11c68278e24c93ba8cc55a7a1cfe71e3539873","original_commit_id":"8f11c68278e24c93ba8cc55a7a1cfe71e3539873","user":{"login":"jlowin","id":153965,"avatar_url":"https://avatars.githubusercontent.com/u/153965?v=3","gravatar_id":"","url":"https://api.github.com/users/jlowin","html_url":"https://github.com/jlowin","followers_url":"https://api.github.com/users/jlowin/followers","following_url":"https://api.github.com/users/jlowin/following{/other_user}","gists_url":"https://api.github.com/users/jlowin/gists{/gist_id}","starred_url":"https://api.github.com/users/jlowin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlowin/subscriptions","organizations_url":"https://api.github.com/users/jlowin/orgs","repos_url":"https://api.github.com/users/jlowin/repos","events_url":"https://api.github.com/users/jlowin/events{/privacy}","received_events_url":"https://api.github.com/users/jlowin/received_events","type":"User","site_admin":false},"body":"I'm not 100% sure about this, but I believe that `shell=True` might make this process ignore termination of the parent process. We don't want that since Airflow uses subprocesses to run/manage tasks. Is it possible to use `shell=False` and maybe something like `shlex.split(hdfs_cmd)` because then you need a list?","created_at":"2016-05-06T17:31:23Z","updated_at":"2016-05-06T17:31:23Z","html_url":"https://github.com/apache/incubator-airflow/pull/1409#discussion_r62362097","pull_request_url":"https://api.github.com/repos/apache/incubator-airflow/pulls/1409","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/comments/62362097"},"html":{"href":"https://github.com/apache/incubator-airflow/pull/1409#discussion_r62362097"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/1409"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-airflow/pulls/1409","id":67140053,"html_url":"https://github.com/apache/incubator-airflow/pull/1409","diff_url":"https://github.com/apache/incubator-airflow/pull/1409.diff","patch_url":"https://github.com/apache/incubator-airflow/pull/1409.patch","issue_url":"https://api.github.com/repos/apache/incubator-airflow/issues/1409","number":1409,"state":"open","locked":false,"title":"AIRFLOW-55: Added HDFSCliHook & HDFSLog","user":{"login":"wxiang7","id":1909016,"avatar_url":"https://avatars.githubusercontent.com/u/1909016?v=3","gravatar_id":"","url":"https://api.github.com/users/wxiang7","html_url":"https://github.com/wxiang7","followers_url":"https://api.github.com/users/wxiang7/followers","following_url":"https://api.github.com/users/wxiang7/following{/other_user}","gists_url":"https://api.github.com/users/wxiang7/gists{/gist_id}","starred_url":"https://api.github.com/users/wxiang7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wxiang7/subscriptions","organizations_url":"https://api.github.com/users/wxiang7/orgs","repos_url":"https://api.github.com/users/wxiang7/repos","events_url":"https://api.github.com/users/wxiang7/events{/privacy}","received_events_url":"https://api.github.com/users/wxiang7/received_events","type":"User","site_admin":false},"body":"Dear Airflow Maintainers,\r\n\r\nPlease accept the following PR that\r\n* Addresses the following issues (links to issues addressed by this PR) :\r\nn/a\r\n\r\nReminder to contributors:\r\n* You must add an Apache License header to all new files\r\n* Please squash your commits when possible and follow the [7 rules of good Git commits](http://chris.beams.io/posts/git-commit/#seven-rules)\r\n\r\na popen and tail utility\r\n\r\na hdfs cli wrapper\r\n\r\nenable hdfs log\r\n\r\nfix logging\r\n\r\nfix hdfs_cli_hook import\r\n\r\nuse generator for tail function\r\n\r\nadd snakebite as fallback in case hadoop binary is not available\r\n\r\nfix for logging\r\n\r\nFix issues when snakebite process HDFS path starts hdfs://...","created_at":"2016-04-20T07:28:41Z","updated_at":"2016-05-06T17:31:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a6ef8f24588661b11e05688cd697a790ac7648b9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-airflow/pulls/1409/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-airflow/pulls/1409/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-airflow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-airflow/issues/1409/comments","statuses_url":"https://api.github.com/repos/apache/incubator-airflow/statuses/8f11c68278e24c93ba8cc55a7a1cfe71e3539873","head":{"label":"wxiang7:hdfs_log","ref":"hdfs_log","sha":"8f11c68278e24c93ba8cc55a7a1cfe71e3539873","user":{"login":"wxiang7","id":1909016,"avatar_url":"https://avatars.githubusercontent.com/u/1909016?v=3","gravatar_id":"","url":"https://api.github.com/users/wxiang7","html_url":"https://github.com/wxiang7","followers_url":"https://api.github.com/users/wxiang7/followers","following_url":"https://api.github.com/users/wxiang7/following{/other_user}","gists_url":"https://api.github.com/users/wxiang7/gists{/gist_id}","starred_url":"https://api.github.com/users/wxiang7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wxiang7/subscriptions","organizations_url":"https://api.github.com/users/wxiang7/orgs","repos_url":"https://api.github.com/users/wxiang7/repos","events_url":"https://api.github.com/users/wxiang7/events{/privacy}","received_events_url":"https://api.github.com/users/wxiang7/received_events","type":"User","site_admin":false},"repo":{"id":56122755,"name":"airflow","full_name":"wxiang7/airflow","owner":{"login":"wxiang7","id":1909016,"avatar_url":"https://avatars.githubusercontent.com/u/1909016?v=3","gravatar_id":"","url":"https://api.github.com/users/wxiang7","html_url":"https://github.com/wxiang7","followers_url":"https://api.github.com/users/wxiang7/followers","following_url":"https://api.github.com/users/wxiang7/following{/other_user}","gists_url":"https://api.github.com/users/wxiang7/gists{/gist_id}","starred_url":"https://api.github.com/users/wxiang7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wxiang7/subscriptions","organizations_url":"https://api.github.com/users/wxiang7/orgs","repos_url":"https://api.github.com/users/wxiang7/repos","events_url":"https://api.github.com/users/wxiang7/events{/privacy}","received_events_url":"https://api.github.com/users/wxiang7/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wxiang7/airflow","description":"Airflow is a system to programmatically author, schedule and monitor data pipelines.","fork":true,"url":"https://api.github.com/repos/wxiang7/airflow","forks_url":"https://api.github.com/repos/wxiang7/airflow/forks","keys_url":"https://api.github.com/repos/wxiang7/airflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wxiang7/airflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wxiang7/airflow/teams","hooks_url":"https://api.github.com/repos/wxiang7/airflow/hooks","issue_events_url":"https://api.github.com/repos/wxiang7/airflow/issues/events{/number}","events_url":"https://api.github.com/repos/wxiang7/airflow/events","assignees_url":"https://api.github.com/repos/wxiang7/airflow/assignees{/user}","branches_url":"https://api.github.com/repos/wxiang7/airflow/branches{/branch}","tags_url":"https://api.github.com/repos/wxiang7/airflow/tags","blobs_url":"https://api.github.com/repos/wxiang7/airflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wxiang7/airflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wxiang7/airflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/wxiang7/airflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wxiang7/airflow/statuses/{sha}","languages_url":"https://api.github.com/repos/wxiang7/airflow/languages","stargazers_url":"https://api.github.com/repos/wxiang7/airflow/stargazers","contributors_url":"https://api.github.com/repos/wxiang7/airflow/contributors","subscribers_url":"https://api.github.com/repos/wxiang7/airflow/subscribers","subscription_url":"https://api.github.com/repos/wxiang7/airflow/subscription","commits_url":"https://api.github.com/repos/wxiang7/airflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/wxiang7/airflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/wxiang7/airflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/wxiang7/airflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/wxiang7/airflow/contents/{+path}","compare_url":"https://api.github.com/repos/wxiang7/airflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wxiang7/airflow/merges","archive_url":"https://api.github.com/repos/wxiang7/airflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wxiang7/airflow/downloads","issues_url":"https://api.github.com/repos/wxiang7/airflow/issues{/number}","pulls_url":"https://api.github.com/repos/wxiang7/airflow/pulls{/number}","milestones_url":"https://api.github.com/repos/wxiang7/airflow/milestones{/number}","notifications_url":"https://api.github.com/repos/wxiang7/airflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wxiang7/airflow/labels{/name}","releases_url":"https://api.github.com/repos/wxiang7/airflow/releases{/id}","deployments_url":"https://api.github.com/repos/wxiang7/airflow/deployments","created_at":"2016-04-13T05:11:38Z","updated_at":"2016-04-13T05:11:39Z","pushed_at":"2016-05-06T09:05:19Z","git_url":"git://github.com/wxiang7/airflow.git","ssh_url":"git@github.com:wxiang7/airflow.git","clone_url":"https://github.com/wxiang7/airflow.git","svn_url":"https://github.com/wxiang7/airflow","homepage":"","size":8468,"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":"apache:master","ref":"master","sha":"c3614d18673b0ee66d13ff75bf543d8a5c88a465","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":33884891,"name":"incubator-airflow","full_name":"apache/incubator-airflow","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-airflow","description":"Apache Airflow (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-airflow","forks_url":"https://api.github.com/repos/apache/incubator-airflow/forks","keys_url":"https://api.github.com/repos/apache/incubator-airflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-airflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-airflow/teams","hooks_url":"https://api.github.com/repos/apache/incubator-airflow/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-airflow/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-airflow/events","assignees_url":"https://api.github.com/repos/apache/incubator-airflow/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-airflow/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-airflow/tags","blobs_url":"https://api.github.com/repos/apache/incubator-airflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-airflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-airflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-airflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-airflow/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-airflow/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-airflow/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-airflow/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-airflow/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-airflow/subscription","commits_url":"https://api.github.com/repos/apache/incubator-airflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-airflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-airflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-airflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-airflow/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-airflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-airflow/merges","archive_url":"https://api.github.com/repos/apache/incubator-airflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-airflow/downloads","issues_url":"https://api.github.com/repos/apache/incubator-airflow/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-airflow/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-airflow/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-airflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-airflow/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-airflow/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-airflow/deployments","created_at":"2015-04-13T18:04:58Z","updated_at":"2016-05-06T15:39:52Z","pushed_at":"2016-05-06T16:21:10Z","git_url":"git://github.com/apache/incubator-airflow.git","ssh_url":"git@github.com:apache/incubator-airflow.git","clone_url":"https://github.com/apache/incubator-airflow.git","svn_url":"https://github.com/apache/incubator-airflow","homepage":"","size":11799,"stargazers_count":2654,"watchers_count":2654,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":545,"mirror_url":null,"open_issues_count":265,"forks":545,"open_issues":265,"watchers":2654,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/1409"},"html":{"href":"https://github.com/apache/incubator-airflow/pull/1409"},"issue":{"href":"https://api.github.com/repos/apache/incubator-airflow/issues/1409"},"comments":{"href":"https://api.github.com/repos/apache/incubator-airflow/issues/1409/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/1409/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/1409/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-airflow/statuses/8f11c68278e24c93ba8cc55a7a1cfe71e3539873"}}}}