From e5cb2569a65e77acc5105522fa3b4d2488b5302a Mon Sep 17 00:00:00 2001 From: Luong Anh Tuan Date: Mon, 26 Sep 2016 09:24:06 +0700 Subject: [PATCH] Using sys.exit(main()) instead of main() TrivialFix: Similar [1] in Kolla project As we known, Exceptions are raised by the sys.exit() function. When they are not handled, no stack traceback is printed in the Python interpreter. Therefore, when using sys.exit(main()) instead of main() may be more readable and reasonable. [1] https://review.openstack.org/#/c/349353/ Change-Id: Ied52a7631da82a72f0dcf2fc9ed81840d24041d9 --- contrib/ipaextractor.py | 2 +- contrib/zoneextractor.py | 2 +- devstack/networking_test.py | 3 ++- devstack/statsd_mock_server.py | 3 ++- tools/pretty_flake8.py | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/ipaextractor.py b/contrib/ipaextractor.py index 4a209cace..08fa7b763 100644 --- a/contrib/ipaextractor.py +++ b/contrib/ipaextractor.py @@ -362,4 +362,4 @@ def main(): pprint.pformat(resp.json()))) if __name__ == '__main__': - main() + sys.exit(main()) diff --git a/contrib/zoneextractor.py b/contrib/zoneextractor.py index d30f5fd72..5e7abdace 100644 --- a/contrib/zoneextractor.py +++ b/contrib/zoneextractor.py @@ -208,4 +208,4 @@ def main(): LOG.error(e) if __name__ == '__main__': - main() + sys.exit(main()) diff --git a/devstack/networking_test.py b/devstack/networking_test.py index f5ef17596..d6b26ad4c 100644 --- a/devstack/networking_test.py +++ b/devstack/networking_test.py @@ -46,6 +46,7 @@ import os import random import string import time +import sys import dns import dns.resolver @@ -660,4 +661,4 @@ def main(): if __name__ == '__main__': - main() + sys.exit(main()) diff --git a/devstack/statsd_mock_server.py b/devstack/statsd_mock_server.py index d65a45816..2b195d9b2 100755 --- a/devstack/statsd_mock_server.py +++ b/devstack/statsd_mock_server.py @@ -19,6 +19,7 @@ Log to stdout or to a file. """ from argparse import ArgumentParser +import sys from time import gmtime from time import strftime import SocketServer @@ -57,4 +58,4 @@ def main(): server.serve_forever() if __name__ == "__main__": - main() + sys.exit(main()) diff --git a/tools/pretty_flake8.py b/tools/pretty_flake8.py index 2688cccfa..ca7a481dc 100755 --- a/tools/pretty_flake8.py +++ b/tools/pretty_flake8.py @@ -88,4 +88,4 @@ def format_dict(raw): return output if __name__ == '__main__': - main() + sys.exit(main())