From: Alfredo Deza Date: Fri, 15 Aug 2014 16:21:14 +0000 (-0400) Subject: only close stderr if we are not testing X-Git-Tag: v1.5.12~8^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a92bb174a2686f6467237c64523f475ca99b9034;p=ceph-deploy.git only close stderr if we are not testing Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/util/decorators.py b/ceph_deploy/util/decorators.py index 9565729..37fd755 100644 --- a/ceph_deploy/util/decorators.py +++ b/ceph_deploy/util/decorators.py @@ -1,4 +1,5 @@ import logging +import os import sys import traceback from functools import wraps @@ -80,15 +81,16 @@ def catches(catch=None, handler=None, exit=True): # This block is crucial to avoid having issues with # Python spitting non-sense thread exceptions. We have already # handled what we could, so close stderr and stdout. - import sys - try: - sys.stdout.close() - except: - pass - try: - sys.stderr.close() - except: - pass + if not os.environ.get('CEPH_DEPLOY_TEST'): + import sys + try: + sys.stdout.close() + except: + pass + try: + sys.stderr.close() + except: + pass return newfunc