2011-03-08 22:32:27 +03:00
|
|
|
import atexit
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
|
|
|
|
_tmpdirs = set()
|
|
|
|
|
|
|
|
|
|
|
|
def _cleanup():
|
|
|
|
try:
|
|
|
|
import sys
|
|
|
|
import shutil
|
|
|
|
except ImportError:
|
|
|
|
return
|
|
|
|
tmp = None
|
|
|
|
try:
|
|
|
|
for tmp in _tmpdirs:
|
|
|
|
shutil.rmtree(tmp)
|
|
|
|
except Exception, exc:
|
|
|
|
sys.stderr.write("\n** shutil.rmtree(%r): %s\n" % (tmp, exc))
|
|
|
|
|
|
|
|
atexit.register(_cleanup)
|
|
|
|
|
|
|
|
|
|
|
|
def _polite_tmpdir():
|
|
|
|
tmp = tempfile.mkdtemp()
|
|
|
|
_tmpdirs.add(tmp)
|
|
|
|
return tmp
|
|
|
|
|
|
|
|
|
|
|
|
# See settings.py for documentation:
|
|
|
|
NETAPP_STORAGE = _polite_tmpdir()
|
|
|
|
ADDONS_PATH = _polite_tmpdir()
|
|
|
|
GUARDED_ADDONS_PATH = _polite_tmpdir()
|
|
|
|
UPLOADS_PATH = _polite_tmpdir()
|
|
|
|
MIRROR_STAGE_PATH = _polite_tmpdir()
|
2011-04-28 04:44:38 +04:00
|
|
|
TMP_PATH = _polite_tmpdir()
|
2011-04-28 21:28:48 +04:00
|
|
|
COLLECTIONS_ICON_PATH = _polite_tmpdir()
|