{"action":"created","comment":{"url":"https://api.github.com/repos/jessebot/jessebot/pulls/comments/24216995","id":24216995,"diff_hunk":"@@ -7,97 +7,114 @@\n import logging\n import multiprocessing\n import subprocess\n-import sys\n import time\n \n-# enable logging\n-# create timestamp\n+\n fmt = '%Y-%m-%d_%H:%M:%S'\n timestamp = datetime.datetime.utcnow().strftime(fmt)\n base_log = 'base_fancy_rsync-{0}.log'.format(timestamp)\n logging.basicConfig(filename=base_log, level=logging.DEBUG)\n-print \"Fancy Rsync commencing. The base log will be\", base_log, \"Check there for progress details.\"\n+logging.info(\"Fancy Rsync commencing. The base log will be %s. Check there \"\n+             \"for progress details.\", base_log)\n logging.info(\"Fancy Rysnc script: Logging config loaded\")\n \n-# begin functions\n+\n def create_qtree(netapp, volume, qtree, clustermode, vserver=None):\n     \"\"\"Creates qtrees for for given string type variables.\"\"\"\n-    logging.info(\"Creating qtree: {0} in volume: {1} on netapp {2}\".format(qtree, volume, netapp))\n+    logging.info(\"Creating qtree: %s in volume: %s on netapp %s\",\n+                 qtree, volume, netapp)\n+\n+    command = \"qtree create /vol/{0}/{1}\".format(volume, qtree)\n+    user = \"root\"\n+\n     if clustermode:\n-        command = \"vol qtree create -volume {0} -vserver {1} -qtree {2}\".format(volme, vserver, qtree)\n+        command = (\"vol qtree create -volume {0} -vserver {1} -qtree \"\n+                   \"{2}\".format(volume, vserver, qtree))\n         user = \"admin\"\n-    else:\n-        command = \"qtree create /vol/{0}/{1}\".format(volume, qtree)\n-        user = \"root\"\n-    sshProcess = subprocess.Popen([\"ssh\", \"-o\", \"StrictHostKeyChecking=no\", \"-l\", user, netapp, command], \\\n-                                   shell=False, stdin=subprocess.PIPE, stdout = subprocess.PIPE)\n+\n+    sshProcess = subprocess.Popen(\n+        [\"ssh\", \"-o\", \"StrictHostKeyChecking=no\", \"-l\", user, netapp, command],\n+        shell=False, stdin=subprocess.PIPE, stdout = subprocess.PIPE)\n     output = sshProcess.stdout.readlines()\n     logging.info(output)\n \n+\n def check_ownership(source_path):\n     \"\"\" takes string type path variable and returns ownership\"\"\"\n     command = \"stat -c '%U' {0}\".format(source_path)\n-    sshProcess = subprocess.Popen([\"bash\", \"-c\", command], \\\n-                                   shell=False, stdin=subprocess.PIPE, stdout = subprocess.PIPE)\n+    sshProcess = subprocess.Popen(\n+        [\"bash\", \"-c\", command], shell=False, stdin=subprocess.PIPE,\n+        stdout=subprocess.PIPE)\n     return sshProcess.stdout.readlines()\n \n+\n def check_group_ownership(source_path):\n     \"\"\" takes string type path variable and returns group ownership\"\"\"\n     command = \"stat -c '%G' {0}\".format(source_path)\n-    sshProcess = subprocess.Popen([\"bash\", \"-c\", command], \\\n-                                   shell=False, stdin=subprocess.PIPE, stdout = subprocess.PIPE)\n+    sshProcess = subprocess.Popen(\n+        [\"bash\", \"-c\", command], shell=False, stdin=subprocess.PIPE,\n+        stdout=subprocess.PIPE)\n     return sshProcess.stdout.readlines()\n \n+\n def change_ownerships(source_dir, destination_dir, directory=None):\n     \"\"\" Takes source_dir, directory name, and destination dir string type\n         variables and changes the ownership of the destination dir to match\n         the source dir's ownership \"\"\"\n+\n+    source_path = source_dir\n+    destination_path = destination_dir\n+\n     if directory:\n         source_path = \"{0}/{1}\".format(source_dir, directory)\n         destination_path = \"{0}/{1}\".format(destination_dir, directory)\n-    else:\n-        source_path = source_dir\n-        destination_path = destination_dir\n+\n     # grab ownerships of sourcepath\n     owner = check_ownership(source_path)\n     group_owner = check_group_ownership(source_path)\n     command = \"chown {0} {1}\".format(owner, destination_path)\n     logging.info(command)\n-    sshProcess = subprocess.Popen([\"bash\", \"-c\", command], \\\n-                                   shell=False, stdin=subprocess.PIPE, stdout = subprocess.PIPE)\n+    sshProcess = subprocess.Popen(\n+        [\"bash\", \"-c\", command], shell=False, stdin=subprocess.PIPE,\n+        stdout=subprocess.PIPE)\n     command = \"chgrp {0} {1}\".format(group_owner, destination_path)\n     logging.info(command)\n-    sshProcess = subprocess.Popen([\"bash\", \"-c\", command], \\\n-                                   shell=False, stdin=subprocess.PIPE, stdout = subprocess.PIPE)\n+    sshProcess = subprocess.Popen(\n+        [\"bash\", \"-c\", command], shell=False, stdin=subprocess.PIPE,\n+        stdout=subprocess.PIPE)\n+\n \n-def rsync_data(source_dir, destination_dir, directory=None, bandwidth=None, remove=None, extras=None):\n+def rsync_data(source_dir, destination_dir, directory=None, bandwidth=None,\n+               remove=None, extras=None):\n     \"\"\" rsyncs data har har har\"\"\"\n-    # create timestamp\n+\n     fmt = '%Y-%m-%d_%H:%M:%S'\n     timestamp = datetime.datetime.utcnow().strftime(fmt)\n     # sort out if this is a list of directories or a single source and destination\n+\n+    source_path = source_dir\n+    destination_path = destination_dir\n+    command = (\"rsync -ahvu --exclude '.snapshot' {0}/ {1}/\"\n+               .format(source_path, destination_path))\n+    logfile_name = 'fancyrsync-{0}.log'.format(timestamp)\n+\n     if directory:\n         source_path = \"{0}/{1}\".format(source_dir, directory)\n         destination_path = \"{0}/{1}\".format(destination_dir, directory)\n-        command = \"rsync -ahvu --exclude '.snapshot' {0}/ {1}/\".format(source_path, destination_path, timestamp, directory)\n-        logfile = 'fancyrsync-{0}-{1}.log'.format(directory, timestamp)\n-    else:\n-        source_path = source_dir\n-        destination_path = destination_dir\n-        command = \"rsync -ahvu --exclude '.snapshot' {0}/ {1}/\".format(source_path, destination_path)\n-        logfile = 'fancyrsync-{0}.log'.format(timestamp)\n+        command = (\"rsync -ahvu --exclude '.snapshot' {0}/ {1}/\"\n+                   .format(source_path, destination_path))\n+        logfile_name = 'fancyrsync-{0}-{1}.log'.format(directory, timestamp)\n \n     # split command into list for easy digestion with subprocess\n     full_cmd = command.split()\n     logging.info(command)\n-    logging.info(\"log file is {0}\".format(logfile))\n-    # open log file\n-    logfile = open(logfile, 'w')\n+    logging.info(\"log file is {0}\".format(logfile_name))\n+    logfile = open(logfile_name, 'w')\n     logfile.write(command)\n \n     # run through rsync option logic, append values to full_cmd list if\n     # speficied in cli args\n-    if (bandwidth or remove or extras):\n+    if bandwidth or remove or extras:","path":"fancy_rsync.py","position":147,"original_position":147,"commit_id":"42d0dc058251aad87eae39286c76eee9586115ed","original_commit_id":"42d0dc058251aad87eae39286c76eee9586115ed","user":{"login":"tmehlinger","id":732339,"avatar_url":"https://avatars.githubusercontent.com/u/732339?v=3","gravatar_id":"","url":"https://api.github.com/users/tmehlinger","html_url":"https://github.com/tmehlinger","followers_url":"https://api.github.com/users/tmehlinger/followers","following_url":"https://api.github.com/users/tmehlinger/following{/other_user}","gists_url":"https://api.github.com/users/tmehlinger/gists{/gist_id}","starred_url":"https://api.github.com/users/tmehlinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmehlinger/subscriptions","organizations_url":"https://api.github.com/users/tmehlinger/orgs","repos_url":"https://api.github.com/users/tmehlinger/repos","events_url":"https://api.github.com/users/tmehlinger/events{/privacy}","received_events_url":"https://api.github.com/users/tmehlinger/received_events","type":"User","site_admin":false},"body":"More PEP8. No need for parens if it won't span to the next line.","created_at":"2015-02-06T01:33:40Z","updated_at":"2015-02-06T01:33:40Z","html_url":"https://github.com/jessebot/jessebot/pull/2#discussion_r24216995","pull_request_url":"https://api.github.com/repos/jessebot/jessebot/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/jessebot/jessebot/pulls/comments/24216995"},"html":{"href":"https://github.com/jessebot/jessebot/pull/2#discussion_r24216995"},"pull_request":{"href":"https://api.github.com/repos/jessebot/jessebot/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/jessebot/jessebot/pulls/2","id":28777789,"html_url":"https://github.com/jessebot/jessebot/pull/2","diff_url":"https://github.com/jessebot/jessebot/pull/2.diff","patch_url":"https://github.com/jessebot/jessebot/pull/2.patch","issue_url":"https://api.github.com/repos/jessebot/jessebot/issues/2","number":2,"state":"open","locked":false,"title":"PEP8 fixes anc code cleanup.","user":{"login":"tmehlinger","id":732339,"avatar_url":"https://avatars.githubusercontent.com/u/732339?v=3","gravatar_id":"","url":"https://api.github.com/users/tmehlinger","html_url":"https://github.com/tmehlinger","followers_url":"https://api.github.com/users/tmehlinger/followers","following_url":"https://api.github.com/users/tmehlinger/following{/other_user}","gists_url":"https://api.github.com/users/tmehlinger/gists{/gist_id}","starred_url":"https://api.github.com/users/tmehlinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmehlinger/subscriptions","organizations_url":"https://api.github.com/users/tmehlinger/orgs","repos_url":"https://api.github.com/users/tmehlinger/repos","events_url":"https://api.github.com/users/tmehlinger/events{/privacy}","received_events_url":"https://api.github.com/users/tmehlinger/received_events","type":"User","site_admin":false},"body":"I made a few changes to reflect the style documented in PEP8*. I also rearranged some code to reflect general strategies for simplifying code. I'll have more comments among the changes.\r\n\r\n* https://www.python.org/dev/peps/pep-0008/","created_at":"2015-02-06T01:20:38Z","updated_at":"2015-02-06T01:33:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"17241056a164d8bf8b68456eacfbb7c5d5795736","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jessebot/jessebot/pulls/2/commits","review_comments_url":"https://api.github.com/repos/jessebot/jessebot/pulls/2/comments","review_comment_url":"https://api.github.com/repos/jessebot/jessebot/pulls/comments/{number}","comments_url":"https://api.github.com/repos/jessebot/jessebot/issues/2/comments","statuses_url":"https://api.github.com/repos/jessebot/jessebot/statuses/42d0dc058251aad87eae39286c76eee9586115ed","head":{"label":"tmehlinger:master","ref":"master","sha":"42d0dc058251aad87eae39286c76eee9586115ed","user":{"login":"tmehlinger","id":732339,"avatar_url":"https://avatars.githubusercontent.com/u/732339?v=3","gravatar_id":"","url":"https://api.github.com/users/tmehlinger","html_url":"https://github.com/tmehlinger","followers_url":"https://api.github.com/users/tmehlinger/followers","following_url":"https://api.github.com/users/tmehlinger/following{/other_user}","gists_url":"https://api.github.com/users/tmehlinger/gists{/gist_id}","starred_url":"https://api.github.com/users/tmehlinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmehlinger/subscriptions","organizations_url":"https://api.github.com/users/tmehlinger/orgs","repos_url":"https://api.github.com/users/tmehlinger/repos","events_url":"https://api.github.com/users/tmehlinger/events{/privacy}","received_events_url":"https://api.github.com/users/tmehlinger/received_events","type":"User","site_admin":false},"repo":{"id":30387471,"name":"jessebot","full_name":"tmehlinger/jessebot","owner":{"login":"tmehlinger","id":732339,"avatar_url":"https://avatars.githubusercontent.com/u/732339?v=3","gravatar_id":"","url":"https://api.github.com/users/tmehlinger","html_url":"https://github.com/tmehlinger","followers_url":"https://api.github.com/users/tmehlinger/followers","following_url":"https://api.github.com/users/tmehlinger/following{/other_user}","gists_url":"https://api.github.com/users/tmehlinger/gists{/gist_id}","starred_url":"https://api.github.com/users/tmehlinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmehlinger/subscriptions","organizations_url":"https://api.github.com/users/tmehlinger/orgs","repos_url":"https://api.github.com/users/tmehlinger/repos","events_url":"https://api.github.com/users/tmehlinger/events{/privacy}","received_events_url":"https://api.github.com/users/tmehlinger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tmehlinger/jessebot","description":"This is just a mess of random stuff I work on and config files I need as I jump from computer to computer.","fork":true,"url":"https://api.github.com/repos/tmehlinger/jessebot","forks_url":"https://api.github.com/repos/tmehlinger/jessebot/forks","keys_url":"https://api.github.com/repos/tmehlinger/jessebot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tmehlinger/jessebot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tmehlinger/jessebot/teams","hooks_url":"https://api.github.com/repos/tmehlinger/jessebot/hooks","issue_events_url":"https://api.github.com/repos/tmehlinger/jessebot/issues/events{/number}","events_url":"https://api.github.com/repos/tmehlinger/jessebot/events","assignees_url":"https://api.github.com/repos/tmehlinger/jessebot/assignees{/user}","branches_url":"https://api.github.com/repos/tmehlinger/jessebot/branches{/branch}","tags_url":"https://api.github.com/repos/tmehlinger/jessebot/tags","blobs_url":"https://api.github.com/repos/tmehlinger/jessebot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tmehlinger/jessebot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tmehlinger/jessebot/git/refs{/sha}","trees_url":"https://api.github.com/repos/tmehlinger/jessebot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tmehlinger/jessebot/statuses/{sha}","languages_url":"https://api.github.com/repos/tmehlinger/jessebot/languages","stargazers_url":"https://api.github.com/repos/tmehlinger/jessebot/stargazers","contributors_url":"https://api.github.com/repos/tmehlinger/jessebot/contributors","subscribers_url":"https://api.github.com/repos/tmehlinger/jessebot/subscribers","subscription_url":"https://api.github.com/repos/tmehlinger/jessebot/subscription","commits_url":"https://api.github.com/repos/tmehlinger/jessebot/commits{/sha}","git_commits_url":"https://api.github.com/repos/tmehlinger/jessebot/git/commits{/sha}","comments_url":"https://api.github.com/repos/tmehlinger/jessebot/comments{/number}","issue_comment_url":"https://api.github.com/repos/tmehlinger/jessebot/issues/comments/{number}","contents_url":"https://api.github.com/repos/tmehlinger/jessebot/contents/{+path}","compare_url":"https://api.github.com/repos/tmehlinger/jessebot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tmehlinger/jessebot/merges","archive_url":"https://api.github.com/repos/tmehlinger/jessebot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tmehlinger/jessebot/downloads","issues_url":"https://api.github.com/repos/tmehlinger/jessebot/issues{/number}","pulls_url":"https://api.github.com/repos/tmehlinger/jessebot/pulls{/number}","milestones_url":"https://api.github.com/repos/tmehlinger/jessebot/milestones{/number}","notifications_url":"https://api.github.com/repos/tmehlinger/jessebot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tmehlinger/jessebot/labels{/name}","releases_url":"https://api.github.com/repos/tmehlinger/jessebot/releases{/id}","created_at":"2015-02-06T01:02:03Z","updated_at":"2015-02-06T01:19:06Z","pushed_at":"2015-02-06T01:19:06Z","git_url":"git://github.com/tmehlinger/jessebot.git","ssh_url":"git@github.com:tmehlinger/jessebot.git","clone_url":"https://github.com/tmehlinger/jessebot.git","svn_url":"https://github.com/tmehlinger/jessebot","homepage":"","size":206,"stargazers_count":0,"watchers_count":0,"language":"Shell","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":"jessebot:master","ref":"master","sha":"b4743bc296106cdc8e1a19ae02cd727c554668d5","user":{"login":"jessebot","id":2389292,"avatar_url":"https://avatars.githubusercontent.com/u/2389292?v=3","gravatar_id":"","url":"https://api.github.com/users/jessebot","html_url":"https://github.com/jessebot","followers_url":"https://api.github.com/users/jessebot/followers","following_url":"https://api.github.com/users/jessebot/following{/other_user}","gists_url":"https://api.github.com/users/jessebot/gists{/gist_id}","starred_url":"https://api.github.com/users/jessebot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessebot/subscriptions","organizations_url":"https://api.github.com/users/jessebot/orgs","repos_url":"https://api.github.com/users/jessebot/repos","events_url":"https://api.github.com/users/jessebot/events{/privacy}","received_events_url":"https://api.github.com/users/jessebot/received_events","type":"User","site_admin":false},"repo":{"id":10131943,"name":"jessebot","full_name":"jessebot/jessebot","owner":{"login":"jessebot","id":2389292,"avatar_url":"https://avatars.githubusercontent.com/u/2389292?v=3","gravatar_id":"","url":"https://api.github.com/users/jessebot","html_url":"https://github.com/jessebot","followers_url":"https://api.github.com/users/jessebot/followers","following_url":"https://api.github.com/users/jessebot/following{/other_user}","gists_url":"https://api.github.com/users/jessebot/gists{/gist_id}","starred_url":"https://api.github.com/users/jessebot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessebot/subscriptions","organizations_url":"https://api.github.com/users/jessebot/orgs","repos_url":"https://api.github.com/users/jessebot/repos","events_url":"https://api.github.com/users/jessebot/events{/privacy}","received_events_url":"https://api.github.com/users/jessebot/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jessebot/jessebot","description":"This is just a mess of random stuff I work on and config files I need as I jump from computer to computer.","fork":false,"url":"https://api.github.com/repos/jessebot/jessebot","forks_url":"https://api.github.com/repos/jessebot/jessebot/forks","keys_url":"https://api.github.com/repos/jessebot/jessebot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jessebot/jessebot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jessebot/jessebot/teams","hooks_url":"https://api.github.com/repos/jessebot/jessebot/hooks","issue_events_url":"https://api.github.com/repos/jessebot/jessebot/issues/events{/number}","events_url":"https://api.github.com/repos/jessebot/jessebot/events","assignees_url":"https://api.github.com/repos/jessebot/jessebot/assignees{/user}","branches_url":"https://api.github.com/repos/jessebot/jessebot/branches{/branch}","tags_url":"https://api.github.com/repos/jessebot/jessebot/tags","blobs_url":"https://api.github.com/repos/jessebot/jessebot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jessebot/jessebot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jessebot/jessebot/git/refs{/sha}","trees_url":"https://api.github.com/repos/jessebot/jessebot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jessebot/jessebot/statuses/{sha}","languages_url":"https://api.github.com/repos/jessebot/jessebot/languages","stargazers_url":"https://api.github.com/repos/jessebot/jessebot/stargazers","contributors_url":"https://api.github.com/repos/jessebot/jessebot/contributors","subscribers_url":"https://api.github.com/repos/jessebot/jessebot/subscribers","subscription_url":"https://api.github.com/repos/jessebot/jessebot/subscription","commits_url":"https://api.github.com/repos/jessebot/jessebot/commits{/sha}","git_commits_url":"https://api.github.com/repos/jessebot/jessebot/git/commits{/sha}","comments_url":"https://api.github.com/repos/jessebot/jessebot/comments{/number}","issue_comment_url":"https://api.github.com/repos/jessebot/jessebot/issues/comments/{number}","contents_url":"https://api.github.com/repos/jessebot/jessebot/contents/{+path}","compare_url":"https://api.github.com/repos/jessebot/jessebot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jessebot/jessebot/merges","archive_url":"https://api.github.com/repos/jessebot/jessebot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jessebot/jessebot/downloads","issues_url":"https://api.github.com/repos/jessebot/jessebot/issues{/number}","pulls_url":"https://api.github.com/repos/jessebot/jessebot/pulls{/number}","milestones_url":"https://api.github.com/repos/jessebot/jessebot/milestones{/number}","notifications_url":"https://api.github.com/repos/jessebot/jessebot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jessebot/jessebot/labels{/name}","releases_url":"https://api.github.com/repos/jessebot/jessebot/releases{/id}","created_at":"2013-05-17T20:52:50Z","updated_at":"2015-02-06T00:34:44Z","pushed_at":"2015-02-06T00:34:44Z","git_url":"git://github.com/jessebot/jessebot.git","ssh_url":"git@github.com:jessebot/jessebot.git","clone_url":"https://github.com/jessebot/jessebot.git","svn_url":"https://github.com/jessebot/jessebot","homepage":"","size":206,"stargazers_count":1,"watchers_count":1,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jessebot/jessebot/pulls/2"},"html":{"href":"https://github.com/jessebot/jessebot/pull/2"},"issue":{"href":"https://api.github.com/repos/jessebot/jessebot/issues/2"},"comments":{"href":"https://api.github.com/repos/jessebot/jessebot/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/jessebot/jessebot/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/jessebot/jessebot/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/jessebot/jessebot/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/jessebot/jessebot/statuses/42d0dc058251aad87eae39286c76eee9586115ed"}}}}