From 1468b1932f082f26b4c46bfe9c3b60c7e6c77ae1 Mon Sep 17 00:00:00 2001 From: lordwelch Date: Thu, 19 May 2022 20:13:59 -0700 Subject: [PATCH] Fix crash on startup Add publishers.json to pip package Add exception handling to prevent crash --- comicapi/utils.py | 5 ++++- comictaggerlib/main.py | 7 ++++++- setup.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/comicapi/utils.py b/comicapi/utils.py index 5ccfba0..b4e19af 100644 --- a/comicapi/utils.py +++ b/comicapi/utils.py @@ -275,4 +275,7 @@ publishers: dict[str, ImprintDict] = {} def load_publishers() -> None: - update_publishers(json.loads((pathlib.Path(__file__).parent / "data" / "publishers.json").read_text("utf-8"))) + try: + update_publishers(json.loads((pathlib.Path(__file__).parent / "data" / "publishers.json").read_text("utf-8"))) + except Exception: + logger.exception("Failed to load publishers.json; The are no publishers or imprints loaded") diff --git a/comictaggerlib/main.py b/comictaggerlib/main.py index 7752af3..547379a 100755 --- a/comictaggerlib/main.py +++ b/comictaggerlib/main.py @@ -87,6 +87,10 @@ try: qt_exception_hook = UncaughtHook() from comictaggerlib.taggerwindow import TaggerWindow except ImportError as e: + + def show_exception_box(log_msg: str): + pass + logger.error(str(e)) qt_available = False @@ -101,8 +105,9 @@ def update_publishers() -> None: if json_file.exists(): try: utils.update_publishers(json.loads(json_file.read_text("utf-8"))) - except Exception: + except Exception as e: logger.exception("Failed to load publishers from %s", json_file) + show_exception_box(str(e)) def ctmain() -> None: diff --git a/setup.py b/setup.py index 270e471..f2267da 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ setup( url="https://github.com/comictagger/comictagger", packages=["comictaggerlib", "comicapi"], package_data={ - "comictaggerlib": ["ui/*", "graphics/*"], + "comictaggerlib": ["ui/*", "graphics/*", "data/*"], }, entry_points=dict(console_scripts=["comictagger=comictaggerlib.main:ctmain"]), classifiers=[