mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-25 02:57:22 +00:00
Added names for jobs to make log more readable
Bugfix logging delete thumbnail
This commit is contained in:
parent
ec53570118
commit
c0d0660986
@ -30,15 +30,15 @@ def get_scheduled_tasks(reconnect=True):
|
|||||||
|
|
||||||
# Reconnect Calibre database (metadata.db)
|
# Reconnect Calibre database (metadata.db)
|
||||||
if reconnect:
|
if reconnect:
|
||||||
tasks.append(lambda: TaskReconnectDatabase())
|
tasks.append([lambda: TaskReconnectDatabase(), 'reconnect'])
|
||||||
|
|
||||||
# Generate all missing book cover thumbnails
|
# Generate all missing book cover thumbnails
|
||||||
if config.schedule_generate_book_covers:
|
if config.schedule_generate_book_covers:
|
||||||
tasks.append(lambda: TaskGenerateCoverThumbnails())
|
tasks.append([lambda: TaskGenerateCoverThumbnails(), 'generate book covers'])
|
||||||
|
|
||||||
# Generate all missing series thumbnails
|
# Generate all missing series thumbnails
|
||||||
if config.schedule_generate_series_covers:
|
if config.schedule_generate_series_covers:
|
||||||
tasks.append(lambda: TaskGenerateSeriesThumbnails())
|
tasks.append([lambda: TaskGenerateSeriesThumbnails(), 'generate book covers'])
|
||||||
|
|
||||||
return tasks
|
return tasks
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ def register_scheduled_tasks():
|
|||||||
# Register scheduled tasks
|
# Register scheduled tasks
|
||||||
if start != end:
|
if start != end:
|
||||||
scheduler.schedule_tasks(tasks=get_scheduled_tasks(), trigger='cron', hour=start)
|
scheduler.schedule_tasks(tasks=get_scheduled_tasks(), trigger='cron', hour=start)
|
||||||
scheduler.schedule(func=end_scheduled_tasks, trigger='cron', hour=end)
|
scheduler.schedule(func=end_scheduled_tasks, trigger='cron', name="end scheduled task", hour=end)
|
||||||
|
|
||||||
# Kick-off tasks, if they should currently be running
|
# Kick-off tasks, if they should currently be running
|
||||||
if should_task_be_running(start, end):
|
if should_task_be_running(start, end):
|
||||||
|
@ -47,37 +47,37 @@ class BackgroundScheduler:
|
|||||||
|
|
||||||
return cls._instance
|
return cls._instance
|
||||||
|
|
||||||
def schedule(self, func, trigger, **trigger_args):
|
def schedule(self, func, trigger, name=None, **trigger_args):
|
||||||
if use_APScheduler:
|
if use_APScheduler:
|
||||||
return self.scheduler.add_job(func=func, trigger=trigger, **trigger_args)
|
return self.scheduler.add_job(func=func, trigger=trigger, name=name, **trigger_args)
|
||||||
|
|
||||||
# Expects a lambda expression for the task
|
# Expects a lambda expression for the task
|
||||||
def schedule_task(self, task, user=None, trigger='cron', **trigger_args):
|
def schedule_task(self, task, user=None, name=None, trigger='cron', **trigger_args):
|
||||||
if use_APScheduler:
|
if use_APScheduler:
|
||||||
def scheduled_task():
|
def scheduled_task():
|
||||||
worker_task = task()
|
worker_task = task()
|
||||||
worker_task.scheduled = True
|
worker_task.scheduled = True
|
||||||
WorkerThread.add(user, worker_task)
|
WorkerThread.add(user, worker_task)
|
||||||
return self.schedule(func=scheduled_task, trigger=trigger, **trigger_args)
|
return self.schedule(func=scheduled_task, trigger=trigger, name=name, **trigger_args)
|
||||||
|
|
||||||
# Expects a list of lambda expressions for the tasks
|
# Expects a list of lambda expressions for the tasks
|
||||||
def schedule_tasks(self, tasks, user=None, trigger='cron', **trigger_args):
|
def schedule_tasks(self, tasks, user=None, trigger='cron', **trigger_args):
|
||||||
if use_APScheduler:
|
if use_APScheduler:
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
self.schedule_task(task, user=user, trigger=trigger, **trigger_args)
|
self.schedule_task(task[0], user=user, trigger=trigger, name=task[1], **trigger_args)
|
||||||
|
|
||||||
# Expects a lambda expression for the task
|
# Expects a lambda expression for the task
|
||||||
def schedule_task_immediately(self, task, user=None):
|
def schedule_task_immediately(self, task, user=None, name=None):
|
||||||
if use_APScheduler:
|
if use_APScheduler:
|
||||||
def immediate_task():
|
def immediate_task():
|
||||||
WorkerThread.add(user, task())
|
WorkerThread.add(user, task())
|
||||||
return self.schedule(func=immediate_task, trigger='date')
|
return self.schedule(func=immediate_task, trigger='date', name=name)
|
||||||
|
|
||||||
# Expects a list of lambda expressions for the tasks
|
# Expects a list of lambda expressions for the tasks
|
||||||
def schedule_tasks_immediately(self, tasks, user=None):
|
def schedule_tasks_immediately(self, tasks, user=None):
|
||||||
if use_APScheduler:
|
if use_APScheduler:
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
self.schedule_task_immediately(task, user)
|
self.schedule_task_immediately(task[0], user, name="immediately " + task[1])
|
||||||
|
|
||||||
# Remove all jobs
|
# Remove all jobs
|
||||||
def remove_all_jobs(self):
|
def remove_all_jobs(self):
|
||||||
|
@ -487,7 +487,10 @@ class TaskClearCoverThumbnailCache(CalibreTask):
|
|||||||
return 'ThumbnailsClear'
|
return 'ThumbnailsClear'
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Delete Thumbnail cache directory"
|
if self.book_id > 0:
|
||||||
|
return "Delete Thumbnail cache for book " + str(self.book_id)
|
||||||
|
else:
|
||||||
|
return "Delete Thumbnail cache directory"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_cancellable(self):
|
def is_cancellable(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user