Reworking updating process

This commit is contained in:
morpheus65535 2018-06-04 23:25:07 -04:00
parent 6a978ba19b
commit 60e0dc7b0d
1 changed files with 8 additions and 6 deletions

View File

@ -26,14 +26,16 @@ def gitconfig():
def check_and_apply_update():
gitconfig()
g = git.cmd.Git(current_working_directory)
result = g.pull('origin', branch)
if result.startswith('Already'):
result = g.diff('--shortstat', 'origin/' + branch)
if len(result) == 0:
logging.info('No new version of Bazarr available.')
elif result.startswith('Updating') or result.startswith('Merge made'):
logging.info('Bazarr updated to latest version and need to be restarted.')
updated()
else:
logging.info(result)
g.reset('--hard', 'HEAD')
g.checkout(branch)
g.reset('--hard','origin/' + branch)
g.pull('origin/' + branch)
logging.info('Bazarr updated to latest version and need to be restarted. ' + result)
updated()
def updated():
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)