Skip to content

Commit 83a3777

Browse files
committed
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.
1 parent 3bd335b commit 83a3777

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
]
1414

1515
[project.scripts]
16-
checkmk-weblate-syncer = "checkmk_weblate_syncer:__main__"
16+
checkmk-weblate-syncer = "checkmk_weblate_syncer.__main__:main"
1717

1818
[build-system]
1919
requires = ["hatchling"]

src/checkmk_weblate_syncer/__main__.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,26 @@
99
from .update_translations import run as run_update_translations
1010

1111

12-
def _main() -> None:
12+
def main() -> int:
1313
args = parse_arguments()
1414
configure_logger(args.log_level)
1515

1616
match args.mode:
1717
case Mode.UPDATE_SOURCES:
18-
sys.exit(
19-
run_update_sources(_load_config(args.config_path, UpdateSourcesConfig)),
18+
return run_update_sources(
19+
_load_config(args.config_path, UpdateSourcesConfig)
2020
)
2121
case Mode.UPDATE_TRANSLATIONS:
22-
sys.exit(
23-
run_update_translations(
24-
_load_config(args.config_path, UpdateTranslationsConfig),
25-
),
22+
return run_update_translations(
23+
_load_config(args.config_path, UpdateTranslationsConfig)
2624
)
2725
case _:
2826
assert_never(args.mode)
2927

3028

29+
if __name__ == "__main__":
30+
sys.exit(main())
31+
3132
_ConfigTypeT = TypeVar("_ConfigTypeT", UpdateSourcesConfig, UpdateTranslationsConfig)
3233

3334

@@ -37,6 +38,3 @@ def _load_config(config_path: Path, config_type: type[_ConfigTypeT]) -> _ConfigT
3738
except Exception:
3839
LOGGER.error("Loading config failed")
3940
raise
40-
41-
42-
_main()

0 commit comments

Comments
 (0)