diff options
| author | zhuzeyu <zhu.zeyu@zte.com.cn> | 2017-03-16 09:34:17 +0800 |
|---|---|---|
| committer | zhuzeyu <zhu.zeyu@zte.com.cn> | 2017-03-30 13:57:11 +0800 |
| commit | 730cd93771e4d1fcf41351e80f8cc8540c563bc7 (patch) | |
| tree | ac92ba12fca59b5072cd2c427e81ddb98692b855 /docker/base | |
| parent | cf6883b82b9b14a440aa748319430f6f424c2293 (diff) | |
| download | kolla-730cd93771e4d1fcf41351e80f8cc8540c563bc7.tar.gz kolla-730cd93771e4d1fcf41351e80f8cc8540c563bc7.zip | |
Optimize the code
Keeping function code together can make the structure clear
Change-Id: Ia16b43b902543bc57869579acba2f6b3d5f2ca54
Diffstat (limited to 'docker/base')
| -rw-r--r-- | docker/base/set_configs.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/docker/base/set_configs.py b/docker/base/set_configs.py index a2d875a47..9c3d1f1e4 100644 --- a/docker/base/set_configs.py +++ b/docker/base/set_configs.py @@ -392,28 +392,27 @@ def execute_config_check(config): def main(): - parser = argparse.ArgumentParser() - parser.add_argument('--check', - action='store_true', - required=False, - help='Check whether the configs changed') - args = parser.parse_args() - config = load_config() - - if args.check: - execute_config_check(config) - else: - execute_config_strategy(config) - - -if __name__ == "__main__": - _exit_code = 0 try: - main() + parser = argparse.ArgumentParser() + parser.add_argument('--check', + action='store_true', + required=False, + help='Check whether the configs changed') + args = parser.parse_args() + config = load_config() + + if args.check: + execute_config_check(config) + else: + execute_config_strategy(config) except ExitingException as e: LOG.error("%s: %s", e.__class__.__name__, e) - _exit_code = e.exit_code + return e.exit_code except Exception: LOG.exception('Unexpected error:') - _exit_code = 2 - sys.exit(_exit_code) + return 2 + return 0 + + +if __name__ == "__main__": + sys.exit(main()) |
