Fixed up some return values when github can't be contacted

This commit is contained in:
rembo10
2012-06-18 16:20:31 +05:30
parent 44acb9761d
commit d5b8a90ae4

View File

@@ -6,7 +6,7 @@ from headphones import logger, version
import lib.simplejson as simplejson import lib.simplejson as simplejson
user = "rembo10" user = "rembo10"
branch = "gh_api" branch = "master"
def runGit(args): def runGit(args):
@@ -100,6 +100,8 @@ def checkGithub():
headphones.LATEST_VERSION = git['sha'] headphones.LATEST_VERSION = git['sha']
except: except:
logger.warn('Could not get the latest commit from github') logger.warn('Could not get the latest commit from github')
headphones.COMMITS_BEHIND = 0
return headphones.CURRENT_VERSION
# See how many commits behind we are # See how many commits behind we are
if headphones.CURRENT_VERSION: if headphones.CURRENT_VERSION:
@@ -112,6 +114,8 @@ def checkGithub():
headphones.COMMITS_BEHIND = git['total_commits'] headphones.COMMITS_BEHIND = git['total_commits']
except: except:
logger.warn('Could not get commits behind from github') logger.warn('Could not get commits behind from github')
headphones.COMMITS_BEHIND = 0
return headphones.CURRENT_VERSION
if headphones.COMMITS_BEHIND >= 1: if headphones.COMMITS_BEHIND >= 1:
logger.info('New version is available. You are %s commits behind' % headphones.COMMITS_BEHIND) logger.info('New version is available. You are %s commits behind' % headphones.COMMITS_BEHIND)