From 41f7679062af0b759ee5223d4d7c155340b6044d Mon Sep 17 00:00:00 2001 From: xiaozhuangqing Date: Wed, 7 Sep 2016 13:59:51 +0800 Subject: [PATCH] Make shell main() specify return value in exit code sys.exit() calls in main() will make the interactive python interpreter exit. We can call the main() as below to avoid to exit the interactive interpreter, and specify the return value of main() in the exit code at the same time. sys.exit(main()) also see: I6ead9853fe27e99df3e9121478e906a06839f48c Change-Id: I3086dc0529c4343f246f543de1b6ee6540438a98 --- senlinclient/shell.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/senlinclient/shell.py b/senlinclient/shell.py index 75dd973d..05b3916e 100644 --- a/senlinclient/shell.py +++ b/senlinclient/shell.py @@ -308,13 +308,13 @@ def main(args=None): SenlinShell().main(args) except KeyboardInterrupt: print(_("... terminating senlin client"), file=sys.stderr) - sys.exit(130) + return 130 except Exception as e: if '--debug' in args or '-d' in args: raise else: print(encodeutils.safe_encode(six.text_type(e)), file=sys.stderr) - sys.exit(1) + return 1 if __name__ == "__main__": - main() + sys.exit(main())