HWRF  trunk@4391
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
hwrf_scrub.Deleter Class Reference

Recursive directory deleter with safeguards to prevent accidental deletion of certain critical directories. More...

Detailed Description

Recursive directory deleter with safeguards to prevent accidental deletion of certain critical directories.

Definition at line 28 of file hwrf_scrub.py.

Inheritance diagram for hwrf_scrub.Deleter:

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...
 

Constructor & Destructor Documentation

def hwrf_scrub.Deleter.__init__ (   self,
  logger 
)

Constructor for Deleter.

Parameters
loggera logging.Logger for log messages

Definition at line 31 of file hwrf_scrub.py.

Member Function Documentation

def hwrf_scrub.Deleter._rmtree_onerr (   self,
  function,
  path,
  exc_info 
)
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.

Parameters
functionthe funciton that failed
paththe path to the function that caused problems
exc_infothe exception information
Postcondition
self.badflag=True

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.

Parameters
dirnamethe 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()

Parameters
max_rmdir_loopThe 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())

Returns
the number of directories to delete

Definition at line 115 of file hwrf_scrub.py.

Referenced by hwrf_scrub.Deleter.go().

def hwrf_scrub.Deleter.rmtree (   self,
  tree 
)
protected

Deletes the tree, if possible.

Parameters
treethe 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:

  • /
  • a mount point
  • Any of $HOMEhwrf, $USHhwrf, $EXhwrf, $PARMhwrf, $FIXhwrf, or $FIXgsi
Parameters
normthe path to check

Definition at line 46 of file hwrf_scrub.py.

Referenced by hwrf_scrub.Deleter.add().


The documentation for this class was generated from the following file: