From 430a31812ccdd9408a09dff5d1de63b224122884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Herbel?= Date: Mon, 30 Jun 2025 15:30:00 +0200 Subject: [PATCH] Fix `checkmk-weblate-syncer` script The script ran normally, since it called `sys.exit` on its own. However, the intended way of specifying scripts is to return an integer. The `sys.exit` call is added in the generated Python script. --- pyproject.toml | 2 +- src/checkmk_weblate_syncer/__main__.py | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8139282..59be155 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ dependencies = [ ] [project.scripts] -checkmk-weblate-syncer = "checkmk_weblate_syncer:__main__" +checkmk-weblate-syncer = "checkmk_weblate_syncer.__main__:main" [build-system] requires = ["hatchling"] diff --git a/src/checkmk_weblate_syncer/__main__.py b/src/checkmk_weblate_syncer/__main__.py index 641f58c..e81a34f 100644 --- a/src/checkmk_weblate_syncer/__main__.py +++ b/src/checkmk_weblate_syncer/__main__.py @@ -9,25 +9,26 @@ from .update_translations import run as run_update_translations -def _main() -> None: +def main() -> int: args = parse_arguments() configure_logger(args.log_level) match args.mode: case Mode.UPDATE_SOURCES: - sys.exit( - run_update_sources(_load_config(args.config_path, UpdateSourcesConfig)), + return run_update_sources( + _load_config(args.config_path, UpdateSourcesConfig) ) case Mode.UPDATE_TRANSLATIONS: - sys.exit( - run_update_translations( - _load_config(args.config_path, UpdateTranslationsConfig), - ), + return run_update_translations( + _load_config(args.config_path, UpdateTranslationsConfig) ) case _: assert_never(args.mode) +if __name__ == "__main__": + sys.exit(main()) + _ConfigTypeT = TypeVar("_ConfigTypeT", UpdateSourcesConfig, UpdateTranslationsConfig) @@ -37,6 +38,3 @@ def _load_config(config_path: Path, config_type: type[_ConfigTypeT]) -> _ConfigT except Exception: LOGGER.error("Loading config failed") raise - - -_main()