Commit 17055a9a authored by Barry Warsaw's avatar Barry Warsaw

cleanup(): Add both a method to FileStorage and a module global

function to clean up all the files that a FileStorage creates.
Sometimes it's handy to do a cleanup if you have the instance, other
times you only have the Data.fs file name.
parent 93ef15e3
......@@ -14,11 +14,12 @@
"""Base class for BerkeleyStorage implementations.
"""
__version__ = '$Revision: 1.33 $'.split()[-2:][0]
__version__ = '$Revision: 1.34 $'.split()[-2:][0]
import os
import time
import errno
import shutil
import threading
from types import StringType
......@@ -431,6 +432,10 @@ class BerkeleyBase(BaseStorage):
finally:
self._lock_release()
def cleanup(self):
"""Remove the entire environment directory for this storage."""
cleanup(self._env.db_home)
def env_from_string(envname, config):
......@@ -474,6 +479,16 @@ def env_from_string(envname, config):
return env, lockfile
def cleanup(envdir):
"""Remove the entire environment directory for a Berkeley storage."""
try:
shutil.rmtree(envdir)
except OSError, e:
if e.errno <> errno.ENOENT:
raise
class _WorkThread(threading.Thread):
NAME = 'worker'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment