HWRF
trunk@4391
|
Recursive directory deleter with safeguards to prevent accidental deletion of certain critical directories. More...
Recursive directory deleter with safeguards to prevent accidental deletion of certain critical directories.
Definition at line 28 of file hwrf_scrub.py.
Public Member Functions | |
def | __init__ (self, logger) |
Constructor for Deleter. More... | |
def | logger (self) |
Returns the logging.Logger used for log messages. | |
def | validate_path (self, norm) |
Checks to see if the given path is one that should not be deleted. More... | |
def | add (self, dirname) |
Adds a directory to the list to be deleted. More... | |
def | have_dirs (self) |
Are there any directories to delete (ones passed to add()) More... | |
def | swap_dirs (self) |
Returns the list of directories to delete and clears the internal list. More... | |
def | go |
Deletes all directories sent to add() More... | |
Public Attributes | |
badflag | |
If True, then at least one directory had trouble being deleted. | |
Protected Member Functions | |
def | _rmtree_onerr (self, function, path, exc_info) |
Internal function used to log errors. More... | |
def | rmtree (self, tree) |
Deletes the tree, if possible. More... | |
def hwrf_scrub.Deleter.__init__ | ( | self, | |
logger | |||
) |
Constructor for Deleter.
logger | a logging.Logger for log messages |
Definition at line 31 of file hwrf_scrub.py.
|
protected |
Internal function used to log errors.
This is an internal implementation function called by shutil.rmtree when an underlying function call failed. See the Python documentation of shutil.rmtree for details.
function | the funciton that failed |
path | the path to the function that caused problems |
exc_info | the exception information |
Definition at line 85 of file hwrf_scrub.py.
Referenced by hwrf_scrub.Deleter.rmtree().
def hwrf_scrub.Deleter.add | ( | self, | |
dirname | |||
) |
Adds a directory to the list to be deleted.
The directory is passed through various safeguards first.
dirname | the directory to delete |
Definition at line 70 of file hwrf_scrub.py.
Referenced by produtil.fileop.FileWaiter.add().
def hwrf_scrub.Deleter.go | ( | self, | |
max_rmdir_loop = 30 |
|||
) |
Deletes all directories sent to add()
max_rmdir_loop | The maximum number of directories to delete before returning. This is a safeguard against accidents. |
Definition at line 127 of file hwrf_scrub.py.
def hwrf_scrub.Deleter.have_dirs | ( | self | ) |
Are there any directories to delete (ones passed to add())
Definition at line 115 of file hwrf_scrub.py.
Referenced by hwrf_scrub.Deleter.go().
|
protected |
Deletes the tree, if possible.
tree | the directory tree to delete |
Definition at line 100 of file hwrf_scrub.py.
Referenced by hwrf.prep.PrepHybrid.clean(), and hwrf_scrub.Deleter.go().
def hwrf_scrub.Deleter.swap_dirs | ( | self | ) |
Returns the list of directories to delete and clears the internal list.
Definition at line 120 of file hwrf_scrub.py.
Referenced by hwrf_scrub.Deleter.go().
def hwrf_scrub.Deleter.validate_path | ( | self, | |
norm | |||
) |
Checks to see if the given path is one that should not be deleted.
Raises WillNotDelete if the given directory is one of these:
norm | the path to check |
Definition at line 46 of file hwrf_scrub.py.
Referenced by hwrf_scrub.Deleter.add().