diff options
| author | historia <historiavg@proton.me> | 2026-08-25 19:15:43 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-25 19:15:43 -0400 |
| commit | 757588321d4c27889be6e8e3c12b75873ad1218d (patch) | |
| tree | f5550ef214a1939ba5844b7d91abdabb4171a48f /app/ui/runview.py | |
| parent | 8c9a782dfe94525dc5f0893c98fd19543648264b (diff) | |
| download | tts-audiobook-generator-757588321d4c27889be6e8e3c12b75873ad1218d.tar.gz | |
fix: book generation logging
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"}) |
