From b7f1cbaa5ca5c1d02b7af518b9336ea385e1425d Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Wed, 18 Mar 2015 14:12:10 -0400 Subject: [PATCH] * In tmpdir cleanup: Replaced stray debug printout with a warning msg if tmpdir is not to be cleaned up. --- file/tmpdir.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/file/tmpdir.py b/file/tmpdir.py index 3e0dc14..3000a36 100644 --- a/file/tmpdir.py +++ b/file/tmpdir.py @@ -29,6 +29,7 @@ But this must be added before the first tmpdir() function call. import os import os.path +import sys import tempfile from warnings import warn @@ -65,12 +66,20 @@ def tmpdir(): def tmpdir_exitfunc(): global TMPDIR global TMPDIR_CLEANUP - print "TMPDIR_CLEANUP = ", TMPDIR_CLEANUP - if TMPDIR != None and os.path.isdir(TMPDIR) and TMPDIR_CLEANUP: - try: - sh.rm("-rf", TMPDIR) - except: - warn("Failed to remove temporary directory %s" % TMPDIR) + #print "TMPDIR_CLEANUP = ", TMPDIR_CLEANUP + if TMPDIR != None and os.path.isdir(TMPDIR): + if TMPDIR_CLEANUP: + try: + sh.rm("-rf", TMPDIR) + except: + try: + sh.ls("-al", TMPDIR) + except: + pass + warn("Failed to remove temporary directory %s" % TMPDIR) + else: + pass + sys.stderr.write("wpylib.file.tmpdir: temp dir not cleaned up: %s\n" % TMPDIR) atexit.register(tmpdir_exitfunc) return TMPDIR