* In tmpdir cleanup: Replaced stray debug printout with a warning msg if

tmpdir is not to be cleaned up.
master
Wirawan Purwanto 10 years ago
parent 7568f5874e
commit b7f1cbaa5c
  1. 21
      file/tmpdir.py

@ -29,6 +29,7 @@ But this must be added before the first tmpdir() function call.
import os import os
import os.path import os.path
import sys
import tempfile import tempfile
from warnings import warn from warnings import warn
@ -65,12 +66,20 @@ def tmpdir():
def tmpdir_exitfunc(): def tmpdir_exitfunc():
global TMPDIR global TMPDIR
global TMPDIR_CLEANUP global TMPDIR_CLEANUP
print "TMPDIR_CLEANUP = ", TMPDIR_CLEANUP #print "TMPDIR_CLEANUP = ", TMPDIR_CLEANUP
if TMPDIR != None and os.path.isdir(TMPDIR) and TMPDIR_CLEANUP: if TMPDIR != None and os.path.isdir(TMPDIR):
try: if TMPDIR_CLEANUP:
sh.rm("-rf", TMPDIR) try:
except: sh.rm("-rf", TMPDIR)
warn("Failed to remove temporary directory %s" % 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) atexit.register(tmpdir_exitfunc)
return TMPDIR return TMPDIR

Loading…
Cancel
Save