From: Alfredo Deza Date: Fri, 15 Aug 2014 17:06:31 +0000 (-0400) Subject: make sure we can still exit with proper exit codes X-Git-Tag: v1.5.12~8^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bb32c98aa7239ec480d59343fd49ad2cba7693ae;p=ceph-deploy.git make sure we can still exit with proper exit codes Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/util/decorators.py b/ceph_deploy/util/decorators.py index 37fd755..567d606 100644 --- a/ceph_deploy/util/decorators.py +++ b/ceph_deploy/util/decorators.py @@ -60,6 +60,7 @@ def catches(catch=None, handler=None, exit=True): @wraps(f) def newfunc(*a, **kw): + exit_from_catch = False try: return f(*a, **kw) except catch as e: @@ -68,8 +69,14 @@ def catches(catch=None, handler=None, exit=True): else: logger.error(make_exception_message(e)) if exit: + exit_from_catch = True sys.exit(1) except Exception as err: # anything else + # Make sure we don't spit double tracebacks if we are raising + # SystemExit from the `except catch` block + if exit_from_catch: + sys.exit(1) + str_failure = traceback.format_exc(err) if str_failure: for line in str_failure.split('\n'):