Implemented error handling of github failures

+ added some logging into vcs

Closes bug 1213182

Change-Id: I0fdc497e2fc078da626f757452bb881e2d8e5bfb
This commit is contained in:
Ilya Shakhat
2013-08-20 17:35:17 +04:00
parent e79c4a83f4
commit 79a7915c55
2 changed files with 11 additions and 4 deletions

View File

@@ -16,6 +16,7 @@
import hashlib import hashlib
import json import json
from github import GithubException
from github import MainClass from github import MainClass
from stackalytics.openstack.common import log as logging 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: for project_source in project_sources:
organization = project_source['organization'] organization = project_source['organization']
repos = github.get_organization(organization).get_repos()
LOG.debug('Get list of projects for organization %s', organization) 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: for repo in repos:
repo_uri = repo.git_url repo_uri = repo.git_url

View File

@@ -103,6 +103,7 @@ class Git(Vcs):
if not os.path.exists(self.folder): if not os.path.exists(self.folder):
return {} return {}
LOG.debug('Get release index for repo uri: %s', self.repo['uri'])
os.chdir(self.folder) os.chdir(self.folder)
if not self.release_index: if not self.release_index:
for release in self.repo['releases']: for release in self.repo['releases']:
@@ -118,7 +119,7 @@ class Git(Vcs):
return self.release_index return self.release_index
def log(self, branch, head_commit_id): 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) os.chdir(self.folder)
sh.git('checkout', '%s' % branch) sh.git('checkout', '%s' % branch)
@@ -174,7 +175,7 @@ class Git(Vcs):
yield commit yield commit
def get_last_id(self, branch): 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) os.chdir(self.folder)
sh.git('checkout', '%s' % branch) sh.git('checkout', '%s' % branch)
@@ -183,7 +184,7 @@ class Git(Vcs):
def get_vcs(repo, sources_root): def get_vcs(repo, sources_root):
uri = repo['uri'] 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) match = re.search(r'\.git$', uri)
if match: if match:
return Git(repo, sources_root) return Git(repo, sources_root)