From e3f4f24c3ef89ec8d0e2cb5313e80ccb3ad2898f Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 4 Oct 2020 13:59:33 +0200 Subject: [PATCH] Fixes for failed email and conversions with gdrive --- cps/services/worker.py | 2 +- cps/tasks/convert.py | 6 +++--- cps/tasks/mail.py | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cps/services/worker.py b/cps/services/worker.py index 369522d6..c2ea594c 100644 --- a/cps/services/worker.py +++ b/cps/services/worker.py @@ -210,7 +210,7 @@ class CalibreTask: self._progress = x def _handleError(self, error_message): - log.error(error_message) + log.exception(error_message) self.stat = STAT_FAIL self.progress = 1 self.error = error_message diff --git a/cps/tasks/convert.py b/cps/tasks/convert.py index a41c5ee1..e3857389 100644 --- a/cps/tasks/convert.py +++ b/cps/tasks/convert.py @@ -51,6 +51,8 @@ class TaskConvert(CalibreTask): return error_message filename = self._convert_ebook_format() + if config.config_use_google_drive: + os.remove(self.file_path + u'.' + self.settings['old_book_format'].lower()) if filename: if config.config_use_google_drive: @@ -117,9 +119,7 @@ class TaskConvert(CalibreTask): return self.results['path'] = cur_book.path self.results['title'] = cur_book.title - if config.config_use_google_drive: - os.remove(file_path + format_old_ext) - else: + if not config.config_use_google_drive: self._handleSuccess() return os.path.basename(file_path + format_new_ext) else: diff --git a/cps/tasks/mail.py b/cps/tasks/mail.py index f83cc4fa..ac3ec424 100644 --- a/cps/tasks/mail.py +++ b/cps/tasks/mail.py @@ -169,7 +169,7 @@ class TaskEmail(CalibreTask): except (MemoryError) as e: log.exception(e) self._handleError(u'MemoryError sending email: ' + str(e)) - return None + # return None except (smtplib.SMTPException, smtplib.SMTPAuthenticationError) as e: if hasattr(e, "smtp_error"): text = e.smtp_error.decode('utf-8').replace("\n", '. ') @@ -181,10 +181,11 @@ class TaskEmail(CalibreTask): log.exception(e) text = '' self._handleError(u'Smtplib Error sending email: ' + text) - return None + # return None except (socket.error) as e: self._handleError(u'Socket Error sending email: ' + e.strerror) - return None + # return None + @property def progress(self):