From ee9ef5e790253c29ae761aac2e2f39c449113be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 20:20:44 -0500 Subject: [PATCH] Updating improvement --- bazarr.py | 3 ++- check_update.py | 8 ++++++-- scheduler.py | 4 +++- views/settings.tpl | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bazarr.py b/bazarr.py index 8a4e4fce9..bacf10410 100644 --- a/bazarr.py +++ b/bazarr.py @@ -302,7 +302,8 @@ def save_settings(): def check_update(): ref = request.environ['HTTP_REFERER'] - check_and_apply_update() + result = check_and_apply_update() + logging.info(result) redirect(ref) diff --git a/check_update.py b/check_update.py index 079110077..cbbe97ba3 100644 --- a/check_update.py +++ b/check_update.py @@ -15,13 +15,17 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'): merge_result, _ = repo.merge_analysis(remote_id) # Up to date, do nothing if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE: - print 'Up to date' - return + result = 'No new version of Bazarr available.' + pass # We can just fastforward elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD: repo.checkout_tree(repo.get(remote_id)) master_ref = repo.lookup_reference('refs/heads/master') master_ref.set_target(remote_id) repo.head.set_target(remote_id) + result = 'Bazarr updated to latest version.' + os.execlp('python', 'python', os.path.join(os.path.dirname(__file__), 'bazarr.py')) else: raise AssertionError('Unknown merge analysis result') + + return result diff --git a/scheduler.py b/scheduler.py index 8028fd7c3..7235838a2 100644 --- a/scheduler.py +++ b/scheduler.py @@ -1,3 +1,4 @@ +from get_general_settings import * from get_series import * from get_episodes import * from get_subtitle import * @@ -6,7 +7,8 @@ from check_update import * from apscheduler.schedulers.background import BackgroundScheduler scheduler = BackgroundScheduler() -scheduler.add_job(check_and_apply_update, 'interval', hours=6, max_instances=1, coalesce=True, id='update_bazarr', name='Update bazarr from source on Github') +if automatic == 'True': + scheduler.add_job(check_and_apply_update, 'interval', hours=6, max_instances=1, coalesce=True, id='update_bazarr', name='Update bazarr from source on Github') scheduler.add_job(update_series, 'interval', minutes=1, max_instances=1, coalesce=True, id='update_series', name='Update series list from Sonarr') scheduler.add_job(add_new_episodes, 'interval', minutes=1, max_instances=1, coalesce=True, id='add_new_episodes', name='Add new episodes from Sonarr') scheduler.add_job(wanted_search_missing_subtitles, 'interval', minutes=15, max_instances=1, coalesce=True, id='wanted_search_missing_subtitles', name='Search for wanted subtitles') diff --git a/views/settings.tpl b/views/settings.tpl index 0aaa1f1d5..46a69d3ad 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -236,7 +236,7 @@
- + Check now and update
@@ -372,7 +372,7 @@ ; $('#settings_general_check_update').click(function(){ - window.location.href = '{{base_url}}check_update'; + window.location = '{{base_url}}check_update'; }) $('a:not(.tabs), button:not(.cancel)').click(function(){