From 1f82645e1d3e33c91767321c673e939f45194036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 31 Jan 2020 22:24:47 -0500 Subject: [PATCH] WIP --- bazarr.py | 10 +++++----- bazarr/get_series.py | 6 +++--- bazarr/scheduler.py | 21 --------------------- 3 files changed, 8 insertions(+), 29 deletions(-) diff --git a/bazarr.py b/bazarr.py index 283b44b4a..b2a2f5c48 100644 --- a/bazarr.py +++ b/bazarr.py @@ -65,11 +65,11 @@ class DaemonStatus(ProcessRegistry): remaining_processes.remove(ep) else: if remaining_time > 0: - try: - ep.wait(remaining_time) - remaining_processes.remove(ep) - except subprocess.TimeoutExpired: - pass + try: + ep.wait(remaining_time) + remaining_processes.remove(ep) + except subprocess.TimeoutExpired: + pass elapsed = time.time() - reference_ts remaining_time = timeout - elapsed return remaining_processes diff --git a/bazarr/get_series.py b/bazarr/get_series.py index d0a1c5c86..24f9e6f5d 100644 --- a/bazarr/get_series.py +++ b/bazarr/get_series.py @@ -128,7 +128,7 @@ def update_series(): for series in removed_series: database.execute("DELETE FROM table_shows WHERE sonarrSeriesId=?",(series,)) - event_stream.write(type='series', action='delete', series=series) + event_stream.write(type='series', action='delete', series=series) # Update existing series in DB series_in_db_list = [] @@ -144,7 +144,7 @@ def update_series(): query = dict_converter.convert(updated_series) database.execute('''UPDATE table_shows SET ''' + query.keys_update + ''' WHERE sonarrSeriesId = ?''', query.values + (updated_series['sonarrSeriesId'],)) - event_stream.write(type='series', action='update', series=updated_series['sonarrSeriesId']) + event_stream.write(type='series', action='update', series=updated_series['sonarrSeriesId']) # Insert new series in DB for added_series in series_to_add: @@ -158,7 +158,7 @@ def update_series(): logging.debug('BAZARR unable to insert this series into the database:', path_replace(added_series['path'])) - event_stream.write(type='series', action='insert', series=added_series['sonarrSeriesId']) + event_stream.write(type='series', action='insert', series=added_series['sonarrSeriesId']) logging.debug('BAZARR All series synced from Sonarr into database.') diff --git a/bazarr/scheduler.py b/bazarr/scheduler.py index be7475c57..2fab39767 100644 --- a/bazarr/scheduler.py +++ b/bazarr/scheduler.py @@ -224,24 +224,3 @@ class Scheduler: upgrade_subtitles, IntervalTrigger(hours=int(settings.general.upgrade_frequency)), max_instances=1, coalesce=True, misfire_grace_time=15, id='upgrade_subtitles', name='Upgrade previously downloaded Subtitles', replace_existing=True) - -scheduler.add_job(cache_maintenance, IntervalTrigger(hours=24), max_instances=1, coalesce=True, - misfire_grace_time=15, id='cache_cleanup', name='Cache maintenance') - -schedule_update_job() -sonarr_full_update() -radarr_full_update() -schedule_wanted_search() -schedule_upgrade_subs() -scheduler.start() -if args.no_tasks: - scheduler.pause() - - -def add_job(job, name=None, max_instances=1, coalesce=True, args=None): - scheduler.add_job(job, DateTrigger(run_date=datetime.now()), name=name, id=name, max_instances=max_instances, - coalesce=coalesce, args=args) - - -def shutdown_scheduler(): - scheduler.shutdown(wait=True)