diff options
Diffstat (limited to 'app/ui/runview.py')
| -rw-r--r-- | app/ui/runview.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/app/ui/runview.py b/app/ui/runview.py index d49d949..7ff7ab1 100644 --- a/app/ui/runview.py +++ b/app/ui/runview.py @@ -29,6 +29,7 @@ import io import threading import time from dataclasses import dataclass, field +from datetime import datetime from queue import Empty, Queue from typing import Callable, List, Optional @@ -245,14 +246,30 @@ class RunView: if self._cancel.is_set(): self._queue.put({"kind": "cancelled"}) return + # book_files/planned travel on the config fields; dropping + # any stray duplicates from kwargs keeps convert()'s call + # binding unambiguous. + kwargs = {key: value for key, value in config.kwargs.items() + if key not in ("book_files", "planned")} audiobook.convert(backend=config.backend, progress=self._queue.put, cancel=self._cancel, book_files=config.book_files, planned=config.planned, - **config.kwargs) + **kwargs) except Exception as exc: # noqa: BLE001 - reported to the view self._queue.put({"kind": "error", "message": f"{exc}"}) + # The view points failures at the dated log; a crash that + # happens before the converter configures logging (e.g. bad + # arguments) must still leave its trace there. + if self.config.log_path: + try: + with open(self.config.log_path, "a", + encoding="utf-8") as logf: + logf.write(f"{datetime.now():%Y-%m-%d %H:%M:%S} - " + f"ERROR - {exc}\n") + except (OSError, ValueError): + pass finally: self._queue.put({"kind": "worker_exit"}) |
