]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
make sure we can still exit with proper exit codes
authorAlfredo Deza <alfredo.deza@inktank.com>
Fri, 15 Aug 2014 17:06:31 +0000 (13:06 -0400)
committerAlfredo Deza <alfredo.deza@inktank.com>
Fri, 15 Aug 2014 17:06:31 +0000 (13:06 -0400)
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
ceph_deploy/util/decorators.py

index 37fd755487df2fbca4bfdd993084eaea73f072bc..567d6060f6b8fd4704f41a50ec1578190a2b46fc 100644 (file)
@@ -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'):