From 9477c828ed470f4f5514517cfa1ca9df1ec9588a Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 18 Apr 2021 19:51:57 +0300 Subject: error out if my_repos.py cannot be found --- cgitize/config.py | 4 ++++ cgitize/main.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/cgitize/config.py b/cgitize/config.py index 84c7149..a630d7a 100644 --- a/cgitize/config.py +++ b/cgitize/config.py @@ -5,6 +5,7 @@ import configparser import importlib +import logging import os.path import sys @@ -72,6 +73,9 @@ class Config: def import_my_repos(self): sys.path.append(os.path.dirname(self.my_repos)) + if not os.path.exists(self.my_repos): + logging.error("Couldn't find my_repos.py at: %s", self.my_repos) + return None module_name = os.path.splitext(os.path.basename(self.my_repos))[0] module = importlib.import_module(module_name) return module.MY_REPOS diff --git a/cgitize/main.py b/cgitize/main.py index 7d2632d..0c8f029 100644 --- a/cgitize/main.py +++ b/cgitize/main.py @@ -34,6 +34,8 @@ def main(args=None): with setup_logging(args.verbose): config = Config.read(args.config) my_repos = config.import_my_repos() + if my_repos is None: + return 1 cgit_server = CGitServer(config.clone_url) output = CGitRepositories(config.output, cgit_server, force=args.force) success = True -- cgit v1.2.3