From 033eb03b52d7a96f3e124a0b2f8c7ea0f14646fb Mon Sep 17 00:00:00 2001 From: Michael Still Date: Wed, 24 Jul 2024 19:49:18 +1000 Subject: [PATCH] Provide an exit code when raising SystemExit. This will make it easier for scripts which call OpenStack tools to detect failure if SystemExit isn't caught by the calling code. Change-Id: Ic829b704d1629fcb0d926118367af122c25b7fba --- oslo_config/cfg.py | 2 +- oslo_config/generator.py | 2 +- oslo_config/validator.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/oslo_config/cfg.py b/oslo_config/cfg.py index dbc6a20d..e3b12bef 100644 --- a/oslo_config/cfg.py +++ b/oslo_config/cfg.py @@ -2990,7 +2990,7 @@ class ConfigOpts(abc.Mapping): except ValueError: sys.stderr.write("argument --%s: Invalid %s value: %s\n" % ( opt.dest, repr(opt.type), value)) - raise SystemExit + raise SystemExit(1) def _reload_config_files(self): namespace = self._parse_config_files() diff --git a/oslo_config/generator.py b/oslo_config/generator.py index ea12a922..8f8f85e5 100644 --- a/oslo_config/generator.py +++ b/oslo_config/generator.py @@ -826,7 +826,7 @@ def main(args=None): except cfg.RequiredOptError: conf.print_help() if not sys.argv[1:]: - raise SystemExit + raise SystemExit(1) raise generate(conf) diff --git a/oslo_config/validator.py b/oslo_config/validator.py index 01725547..4ec1a7e3 100644 --- a/oslo_config/validator.py +++ b/oslo_config/validator.py @@ -227,7 +227,7 @@ def main(): except cfg.RequiredOptError: conf.print_help() if not sys.argv[1:]: - raise SystemExit + raise SystemExit(1) raise return _validate(conf)