From 79a7915c555f2fa84157d26bdb30cd774dab3f2a Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Tue, 20 Aug 2013 17:35:17 +0400 Subject: [PATCH] Implemented error handling of github failures + added some logging into vcs Closes bug 1213182 Change-Id: I0fdc497e2fc078da626f757452bb881e2d8e5bfb --- stackalytics/processor/default_data_processor.py | 8 +++++++- stackalytics/processor/vcs.py | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/stackalytics/processor/default_data_processor.py b/stackalytics/processor/default_data_processor.py index 94ad7d8b2..40d1c41f1 100644 --- a/stackalytics/processor/default_data_processor.py +++ b/stackalytics/processor/default_data_processor.py @@ -16,6 +16,7 @@ import hashlib import json +from github import GithubException from github import MainClass from stackalytics.openstack.common import log as logging @@ -54,8 +55,13 @@ def _retrieve_project_list(runtime_storage_inst, project_sources): for project_source in project_sources: organization = project_source['organization'] - repos = github.get_organization(organization).get_repos() LOG.debug('Get list of projects for organization %s', organization) + try: + repos = github.get_organization(organization).get_repos() + except GithubException as e: + LOG.exception(e) + LOG.warn('Fail to retrieve list of projects. Keep it unmodified') + return for repo in repos: repo_uri = repo.git_url diff --git a/stackalytics/processor/vcs.py b/stackalytics/processor/vcs.py index ab83cd546..e5258ee48 100644 --- a/stackalytics/processor/vcs.py +++ b/stackalytics/processor/vcs.py @@ -103,6 +103,7 @@ class Git(Vcs): if not os.path.exists(self.folder): return {} + LOG.debug('Get release index for repo uri: %s', self.repo['uri']) os.chdir(self.folder) if not self.release_index: for release in self.repo['releases']: @@ -118,7 +119,7 @@ class Git(Vcs): return self.release_index def log(self, branch, head_commit_id): - LOG.debug('Parsing git log for repo uri %s' % self.repo['uri']) + LOG.debug('Parsing git log for repo uri %s', self.repo['uri']) os.chdir(self.folder) sh.git('checkout', '%s' % branch) @@ -174,7 +175,7 @@ class Git(Vcs): yield commit def get_last_id(self, branch): - LOG.debug('Get head commit for repo uri %s' % self.repo['uri']) + LOG.debug('Get head commit for repo uri: %s', self.repo['uri']) os.chdir(self.folder) sh.git('checkout', '%s' % branch) @@ -183,7 +184,7 @@ class Git(Vcs): def get_vcs(repo, sources_root): uri = repo['uri'] - LOG.debug('Factory is asked for VCS uri %s' % uri) + LOG.debug('Factory is asked for VCS uri: %s', uri) match = re.search(r'\.git$', uri) if match: return Git(repo, sources_root)