From d063217d6f87a215ba35509ede7c5a62ed4771d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 20 Jun 2019 08:39:46 +0200 Subject: [PATCH] config-dump: Report better error for non-existing sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JIRA: COMPOSE-3624 Signed-off-by: Lubomír Sedlář --- bin/pungi-config-dump | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/pungi-config-dump b/bin/pungi-config-dump index 9260ffa7..91b3fd0c 100755 --- a/bin/pungi-config-dump +++ b/bin/pungi-config-dump @@ -29,8 +29,10 @@ def load_file(source, conf): def load_source(source, conf): if os.path.isfile(source): load_file(source, conf) - else: + elif os.path.isdir(source): load_file(os.path.join(source, "logs/global/config-dump.global.log"), conf) + else: + raise RuntimeError("Source %s is neither file nor directory." % source) def dump_multi_config(conf_file, dest, **kwargs): @@ -200,5 +202,9 @@ def main(): if __name__ == "__main__": - if not main(): - sys.exit(1) + try: + if not main(): + sys.exit(1) + except RuntimeError as exc: + print("Error", str(exc), file=sys.stderr) + sys.exit(2)