From 23d66a0d68ece521b61e4633a3694dfcef765225 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 3 Oct 2020 21:43:48 +0200 Subject: [PATCH] Fix --- cps/helper.py | 2 +- cps/tasks/convert.py | 12 ++++-------- cps/updater.py | 1 + 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index 5178a522..b3fdba73 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -102,7 +102,7 @@ def convert_book_format(book_id, calibrepath, old_book_format, new_book_format, txt = (u"%s -> %s: %s" % (old_book_format, new_book_format, book.title)) settings['old_book_format'] = old_book_format settings['new_book_format'] = new_book_format - WorkerThread.add(user_id, TaskConvert(file_path, book.id, txt, settings, kindle_mail)) + WorkerThread.add(user_id, TaskConvert(file_path, book.id, txt, settings, kindle_mail, user_id)) return None else: error_message = _(u"%(format)s not found: %(fn)s", diff --git a/cps/tasks/convert.py b/cps/tasks/convert.py index b6093dbe..35aceddb 100644 --- a/cps/tasks/convert.py +++ b/cps/tasks/convert.py @@ -20,12 +20,13 @@ log = logger.create() class TaskConvert(CalibreTask): - def __init__(self, file_path, bookid, taskMessage, settings, kindle_mail): + def __init__(self, file_path, bookid, taskMessage, settings, kindle_mail, user=None): super(TaskConvert, self).__init__(taskMessage) self.file_path = file_path self.bookid = bookid self.settings = settings self.kindle_mail = kindle_mail + self.user = user self.results = dict() @@ -40,14 +41,9 @@ class TaskConvert(CalibreTask): # if we're sending to kindle after converting, create a one-off task and run it immediately # todo: figure out how to incorporate this into the progress try: - task = TaskEmail(self.settings['subject'], self.results["path"], + worker_thread.add(self.user, TaskEmail(self.settings['subject'], self.results["path"], filename, self.settings, self.kindle_mail, - self.settings['subject'], self.settings['body'], internal=True) - task.start(worker_thread) - - # even though the convert task might be finished, if this task fails, fail the whole thing - if task.stat != STAT_FINISH_SUCCESS: - raise Exception(task.error) + self.settings['subject'], self.settings['body'], internal=True)) except Exception as e: return self._handleError(str(e)) diff --git a/cps/updater.py b/cps/updater.py index e4883370..4a37f688 100644 --- a/cps/updater.py +++ b/cps/updater.py @@ -227,6 +227,7 @@ class Updater(threading.Thread): os.sep + 'vendor', os.sep + 'calibre-web.log', os.sep + '.git', os.sep + 'client_secrets.json', os.sep + 'gdrive_credentials', os.sep + 'settings.yaml', os.sep + 'venv', os.sep + 'virtualenv', os.sep + 'access.log', os.sep + 'access.log1', os.sep + 'access.log2', + os.sep + '.calibre-web.log.swp' ) additional_path = self.is_venv() if additional_path: