{"action":"created","comment":{"url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/comments/89273946","pull_request_review_id":9818663,"id":89273946,"diff_hunk":"@@ -0,0 +1,105 @@\n+# -*- coding: utf-8 -*-\n+from __future__ import unicode_literals\n+\n+from fabric.operations import run\n+from fabric.tasks import execute\n+\n+\n+class LogAnalyzer(object):\n+    \"\"\"Context Manager to analyze changes in logs during some process.\n+    Example:\n+\n+    >>> from automation_tools.satellite6.log import LogAnalyzer\n+    >>> with LogAnalyzer('root@sathost.redhat.com'):\n+    ...     print('Running some process, could be Satellite Upgrade')\n+    ...\n+    [root@sathost.redhat.com] Executing task 'get_line_count'\n+    Running some process, could be Satellite Upgrade\n+    [root@sathost.redhat.com] Executing task 'get_line_count'\n+    [root@sathost.redhat.com] Executing task 'fetch_appended_log_lines'\n+    ### No changes in /var/log/foreman-proxy/proxy.log\n+    ### No changes in /var/log/foreman/production.log\n+    ### No changes in /var/log/foreman-installer/satellite.log\n+    ### No changes in /var/log/candlepin/candlepin.log\n+    ### No changes in /var/log/tomcat/catalina.out\n+    ### No changes in /var/log/messages\n+    ### No changes in /var/log/mongodb/mongodb.log\n+\n+    \"\"\"\n+\n+    def __init__(self, sat_host):\n+        \"\"\"Initializes context manager with Satellite hostname\n+\n+        :param sat_host: str\n+        \"\"\"\n+        self.sat_host = sat_host\n+        self.log_state = {\n+            '/var/log/foreman-installer/satellite.log': 0,\n+            '/var/log/foreman/production.log': 0,\n+            '/var/log/foreman-proxy/proxy.log': 0,\n+            '/var/log/candlepin/candlepin.log': 0,\n+            '/var/log/messages': 0,\n+            '/var/log/mongodb/mongodb.log': 0,\n+            '/var/log/tomcat/catalina.out': 0\n+        }\n+\n+    def __enter__(self):\n+        \"\"\"\n+        Fetch current line count for Satellite log files\n+        :return: LogAnalyzer\n+        \"\"\"\n+        self._update_log_files_state()\n+        return self\n+\n+    def __exit__(self, exc_type, exc_val, exc_tb):\n+        \"\"\"Analyzes log files checking if some error occurred since last\n+        log_state_dct\n+        \"\"\"\n+        self._update_log_files_state()\n+\n+        def analyze(log_file, content):\n+            \"\"\"Analyzes appended content from log file. For now it is only\n+            printing content\n+            \"\"\"\n+            print('### Analyzing %s:' % log_file)\n+            print(content)\n+\n+        def fetch_appended_log_lines():\n+            for log_file, lines_appended in self.log_state.items():\n+                if lines_appended > 0:\n+                    content = run(\n+                        'tail -n {} {}'.format(lines_appended, log_file),\n+                        quiet=True\n+                    )\n+                    analyze(log_file, content)\n+                else:\n+                    print('### No changes in %s' % log_file)","path":"automation_tools/satellite6/log.py","position":76,"original_position":76,"commit_id":"cb0dec3d1455eb4455dac3e2fd356638f876d699","original_commit_id":"cb0dec3d1455eb4455dac3e2fd356638f876d699","user":{"login":"jyejare","id":11752425,"avatar_url":"https://avatars.githubusercontent.com/u/11752425?v=3","gravatar_id":"","url":"https://api.github.com/users/jyejare","html_url":"https://github.com/jyejare","followers_url":"https://api.github.com/users/jyejare/followers","following_url":"https://api.github.com/users/jyejare/following{/other_user}","gists_url":"https://api.github.com/users/jyejare/gists{/gist_id}","starred_url":"https://api.github.com/users/jyejare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyejare/subscriptions","organizations_url":"https://api.github.com/users/jyejare/orgs","repos_url":"https://api.github.com/users/jyejare/repos","events_url":"https://api.github.com/users/jyejare/events{/privacy}","received_events_url":"https://api.github.com/users/jyejare/received_events","type":"User","site_admin":false},"body":"I think this is not rwquired. We just want log file changes if there are. So i am ok to remove else loop.\r\n","created_at":"2016-11-23T08:52:01Z","updated_at":"2016-11-23T08:52:01Z","html_url":"https://github.com/SatelliteQE/automation-tools/pull/459#discussion_r89273946","pull_request_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/459","_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/comments/89273946"},"html":{"href":"https://github.com/SatelliteQE/automation-tools/pull/459#discussion_r89273946"},"pull_request":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/459"}}},"pull_request":{"url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/459","id":94888785,"html_url":"https://github.com/SatelliteQE/automation-tools/pull/459","diff_url":"https://github.com/SatelliteQE/automation-tools/pull/459.diff","patch_url":"https://github.com/SatelliteQE/automation-tools/pull/459.patch","issue_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/459","number":459,"state":"open","locked":false,"title":"Added LogAnalyzer for checking changes on Satellite log files","user":{"login":"renzon","id":3457115,"avatar_url":"https://avatars.githubusercontent.com/u/3457115?v=3","gravatar_id":"","url":"https://api.github.com/users/renzon","html_url":"https://github.com/renzon","followers_url":"https://api.github.com/users/renzon/followers","following_url":"https://api.github.com/users/renzon/following{/other_user}","gists_url":"https://api.github.com/users/renzon/gists{/gist_id}","starred_url":"https://api.github.com/users/renzon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renzon/subscriptions","organizations_url":"https://api.github.com/users/renzon/orgs","repos_url":"https://api.github.com/users/renzon/repos","events_url":"https://api.github.com/users/renzon/events{/privacy}","received_events_url":"https://api.github.com/users/renzon/received_events","type":"User","site_admin":false},"body":"close #447\r\n\r\nContext Manager was added to upgrade task","created_at":"2016-11-22T20:09:10Z","updated_at":"2016-11-23T08:52:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e4c6f2913855c2e99eb1c8abf7e9f2af5dc5eebe","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/459/commits","review_comments_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/459/comments","review_comment_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/459/comments","statuses_url":"https://api.github.com/repos/SatelliteQE/automation-tools/statuses/cb0dec3d1455eb4455dac3e2fd356638f876d699","head":{"label":"renzon:447","ref":"447","sha":"cb0dec3d1455eb4455dac3e2fd356638f876d699","user":{"login":"renzon","id":3457115,"avatar_url":"https://avatars.githubusercontent.com/u/3457115?v=3","gravatar_id":"","url":"https://api.github.com/users/renzon","html_url":"https://github.com/renzon","followers_url":"https://api.github.com/users/renzon/followers","following_url":"https://api.github.com/users/renzon/following{/other_user}","gists_url":"https://api.github.com/users/renzon/gists{/gist_id}","starred_url":"https://api.github.com/users/renzon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renzon/subscriptions","organizations_url":"https://api.github.com/users/renzon/orgs","repos_url":"https://api.github.com/users/renzon/repos","events_url":"https://api.github.com/users/renzon/events{/privacy}","received_events_url":"https://api.github.com/users/renzon/received_events","type":"User","site_admin":false},"repo":{"id":74361173,"name":"automation-tools","full_name":"renzon/automation-tools","owner":{"login":"renzon","id":3457115,"avatar_url":"https://avatars.githubusercontent.com/u/3457115?v=3","gravatar_id":"","url":"https://api.github.com/users/renzon","html_url":"https://github.com/renzon","followers_url":"https://api.github.com/users/renzon/followers","following_url":"https://api.github.com/users/renzon/following{/other_user}","gists_url":"https://api.github.com/users/renzon/gists{/gist_id}","starred_url":"https://api.github.com/users/renzon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renzon/subscriptions","organizations_url":"https://api.github.com/users/renzon/orgs","repos_url":"https://api.github.com/users/renzon/repos","events_url":"https://api.github.com/users/renzon/events{/privacy}","received_events_url":"https://api.github.com/users/renzon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/renzon/automation-tools","description":"A set of tools to help automating testing Foreman with Robottelo (https://github.com/SatelliteQE/robottelo)","fork":true,"url":"https://api.github.com/repos/renzon/automation-tools","forks_url":"https://api.github.com/repos/renzon/automation-tools/forks","keys_url":"https://api.github.com/repos/renzon/automation-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/renzon/automation-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/renzon/automation-tools/teams","hooks_url":"https://api.github.com/repos/renzon/automation-tools/hooks","issue_events_url":"https://api.github.com/repos/renzon/automation-tools/issues/events{/number}","events_url":"https://api.github.com/repos/renzon/automation-tools/events","assignees_url":"https://api.github.com/repos/renzon/automation-tools/assignees{/user}","branches_url":"https://api.github.com/repos/renzon/automation-tools/branches{/branch}","tags_url":"https://api.github.com/repos/renzon/automation-tools/tags","blobs_url":"https://api.github.com/repos/renzon/automation-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/renzon/automation-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/renzon/automation-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/renzon/automation-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/renzon/automation-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/renzon/automation-tools/languages","stargazers_url":"https://api.github.com/repos/renzon/automation-tools/stargazers","contributors_url":"https://api.github.com/repos/renzon/automation-tools/contributors","subscribers_url":"https://api.github.com/repos/renzon/automation-tools/subscribers","subscription_url":"https://api.github.com/repos/renzon/automation-tools/subscription","commits_url":"https://api.github.com/repos/renzon/automation-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/renzon/automation-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/renzon/automation-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/renzon/automation-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/renzon/automation-tools/contents/{+path}","compare_url":"https://api.github.com/repos/renzon/automation-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/renzon/automation-tools/merges","archive_url":"https://api.github.com/repos/renzon/automation-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/renzon/automation-tools/downloads","issues_url":"https://api.github.com/repos/renzon/automation-tools/issues{/number}","pulls_url":"https://api.github.com/repos/renzon/automation-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/renzon/automation-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/renzon/automation-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/renzon/automation-tools/labels{/name}","releases_url":"https://api.github.com/repos/renzon/automation-tools/releases{/id}","deployments_url":"https://api.github.com/repos/renzon/automation-tools/deployments","created_at":"2016-11-21T12:25:12Z","updated_at":"2016-11-21T12:25:14Z","pushed_at":"2016-11-22T20:15:47Z","git_url":"git://github.com/renzon/automation-tools.git","ssh_url":"git@github.com:renzon/automation-tools.git","clone_url":"https://github.com/renzon/automation-tools.git","svn_url":"https://github.com/renzon/automation-tools","homepage":"","size":811,"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":"SatelliteQE:master","ref":"master","sha":"4297a6291478cfadd6bf0c857414c5cf74c4275b","user":{"login":"SatelliteQE","id":8754276,"avatar_url":"https://avatars.githubusercontent.com/u/8754276?v=3","gravatar_id":"","url":"https://api.github.com/users/SatelliteQE","html_url":"https://github.com/SatelliteQE","followers_url":"https://api.github.com/users/SatelliteQE/followers","following_url":"https://api.github.com/users/SatelliteQE/following{/other_user}","gists_url":"https://api.github.com/users/SatelliteQE/gists{/gist_id}","starred_url":"https://api.github.com/users/SatelliteQE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SatelliteQE/subscriptions","organizations_url":"https://api.github.com/users/SatelliteQE/orgs","repos_url":"https://api.github.com/users/SatelliteQE/repos","events_url":"https://api.github.com/users/SatelliteQE/events{/privacy}","received_events_url":"https://api.github.com/users/SatelliteQE/received_events","type":"Organization","site_admin":false},"repo":{"id":22513327,"name":"automation-tools","full_name":"SatelliteQE/automation-tools","owner":{"login":"SatelliteQE","id":8754276,"avatar_url":"https://avatars.githubusercontent.com/u/8754276?v=3","gravatar_id":"","url":"https://api.github.com/users/SatelliteQE","html_url":"https://github.com/SatelliteQE","followers_url":"https://api.github.com/users/SatelliteQE/followers","following_url":"https://api.github.com/users/SatelliteQE/following{/other_user}","gists_url":"https://api.github.com/users/SatelliteQE/gists{/gist_id}","starred_url":"https://api.github.com/users/SatelliteQE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SatelliteQE/subscriptions","organizations_url":"https://api.github.com/users/SatelliteQE/orgs","repos_url":"https://api.github.com/users/SatelliteQE/repos","events_url":"https://api.github.com/users/SatelliteQE/events{/privacy}","received_events_url":"https://api.github.com/users/SatelliteQE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SatelliteQE/automation-tools","description":"A set of tools to help automating testing Foreman with Robottelo (https://github.com/SatelliteQE/robottelo)","fork":false,"url":"https://api.github.com/repos/SatelliteQE/automation-tools","forks_url":"https://api.github.com/repos/SatelliteQE/automation-tools/forks","keys_url":"https://api.github.com/repos/SatelliteQE/automation-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SatelliteQE/automation-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SatelliteQE/automation-tools/teams","hooks_url":"https://api.github.com/repos/SatelliteQE/automation-tools/hooks","issue_events_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/events{/number}","events_url":"https://api.github.com/repos/SatelliteQE/automation-tools/events","assignees_url":"https://api.github.com/repos/SatelliteQE/automation-tools/assignees{/user}","branches_url":"https://api.github.com/repos/SatelliteQE/automation-tools/branches{/branch}","tags_url":"https://api.github.com/repos/SatelliteQE/automation-tools/tags","blobs_url":"https://api.github.com/repos/SatelliteQE/automation-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SatelliteQE/automation-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SatelliteQE/automation-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/SatelliteQE/automation-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SatelliteQE/automation-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/SatelliteQE/automation-tools/languages","stargazers_url":"https://api.github.com/repos/SatelliteQE/automation-tools/stargazers","contributors_url":"https://api.github.com/repos/SatelliteQE/automation-tools/contributors","subscribers_url":"https://api.github.com/repos/SatelliteQE/automation-tools/subscribers","subscription_url":"https://api.github.com/repos/SatelliteQE/automation-tools/subscription","commits_url":"https://api.github.com/repos/SatelliteQE/automation-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/SatelliteQE/automation-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/SatelliteQE/automation-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/SatelliteQE/automation-tools/contents/{+path}","compare_url":"https://api.github.com/repos/SatelliteQE/automation-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SatelliteQE/automation-tools/merges","archive_url":"https://api.github.com/repos/SatelliteQE/automation-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SatelliteQE/automation-tools/downloads","issues_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues{/number}","pulls_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/SatelliteQE/automation-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/SatelliteQE/automation-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SatelliteQE/automation-tools/labels{/name}","releases_url":"https://api.github.com/repos/SatelliteQE/automation-tools/releases{/id}","deployments_url":"https://api.github.com/repos/SatelliteQE/automation-tools/deployments","created_at":"2014-08-01T14:27:34Z","updated_at":"2016-11-04T21:23:39Z","pushed_at":"2016-11-22T20:15:48Z","git_url":"git://github.com/SatelliteQE/automation-tools.git","ssh_url":"git@github.com:SatelliteQE/automation-tools.git","clone_url":"https://github.com/SatelliteQE/automation-tools.git","svn_url":"https://github.com/SatelliteQE/automation-tools","homepage":"","size":1085,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":18,"forks":20,"open_issues":18,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/459"},"html":{"href":"https://github.com/SatelliteQE/automation-tools/pull/459"},"issue":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/459"},"comments":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/459/comments"},"review_comments":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/459/comments"},"review_comment":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/459/commits"},"statuses":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/statuses/cb0dec3d1455eb4455dac3e2fd356638f876d699"}}}}
{"actor":{"display_login":"jyejare"}}