From 021298374e3febc19f87f7b3d6823f32f68b66bd Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 18 Dec 2021 17:31:33 +0100 Subject: [PATCH] Improved debug output for task added Improved handling of calibre output on windows --- cps/tasks/convert.py | 10 ++++++++-- cps/tasks/mail.py | 2 +- cps/tasks/upload.py | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cps/tasks/convert.py b/cps/tasks/convert.py index ada53005..004faec8 100644 --- a/cps/tasks/convert.py +++ b/cps/tasks/convert.py @@ -217,13 +217,16 @@ class TaskConvert(CalibreTask): quotes.append(quotes_index) quotes_index += 1 - p = process_open(command, quotes) + p = process_open(command, quotes, newlines=False) except OSError as e: return 1, _(u"Ebook-converter failed: %(error)s", error=e) while p.poll() is None: nextline = p.stdout.readline() - log.debug(nextline.strip('\r\n')) + if isinstance(nextline, bytes): + nextline = nextline.decode('utf-8', errors="ignore").strip('\r\n') + if nextline: + log.debug(nextline) # parse progress string from calibre-converter progress = re.search(r"(\d+)%\s.*", nextline) if progress: @@ -244,3 +247,6 @@ class TaskConvert(CalibreTask): @property def name(self): return "Convert" + + def __str__(self): + return "Convert {} {}".format(self.bookid, self.kindle_mail) diff --git a/cps/tasks/mail.py b/cps/tasks/mail.py index 2e95ee98..05b2175f 100644 --- a/cps/tasks/mail.py +++ b/cps/tasks/mail.py @@ -267,4 +267,4 @@ class TaskEmail(CalibreTask): return "E-mail" def __str__(self): - return "{}, {}".format(self.name, self.subject) + return "E-mail {}, {}".format(self.name, self.subject) diff --git a/cps/tasks/upload.py b/cps/tasks/upload.py index 6a341cdd..2a667c28 100644 --- a/cps/tasks/upload.py +++ b/cps/tasks/upload.py @@ -32,3 +32,6 @@ class TaskUpload(CalibreTask): @property def name(self): return "Upload" + + def __str__(self): + return "Upload {}".format(self.message)