HWRF  trunk@4391
Public Member Functions | Public Attributes | List of all members
produtil.fileop.FileWaiter Class Reference

A class that waits for files to meet some requirements. More...

Detailed Description

A class that waits for files to meet some requirements.

Definition at line 1037 of file fileop.py.

Public Member Functions

def __init__
 Constructor for the FileWaiter. More...
 
def add (self, flist)
 Adds a file, or iterable that iterates over files, to the list of files to wait for. More...
 
def check
 Checks to see if one file meets the requirements set in the constructor. More...
 
def reset (self)
 Resets internal information about which files have been seen. More...
 
def iterfound (self)
 Iterates over all files that were found. More...
 
def countfound (self)
 Returns the number of files that were found. More...
 
def countmissing (self)
 Returns the number of files that were NOT found. More...
 
def checkfiles
 Looks for the requested files. More...
 

Public Attributes

 min_size
 The minimum file size.
 
 min_mtime_age
 Minimum age of the modification time.
 
 min_atime_age
 Minimum age of the access time.
 
 min_ctime_age
 Minimum age of the creation and/or inode access time.
 
 min_fraction
 The minimum fraction of files that must meet the requirements.
 

Constructor & Destructor Documentation

def produtil.fileop.FileWaiter.__init__ (   self,
  flist = None,
  min_size = None,
  min_mtime_age = None,
  min_atime_age = None,
  min_ctime_age = None,
  min_fraction = 1.0 
)

Constructor for the FileWaiter.

Most arguments have the same meaning as check_file()

Parameters
flistthe file or list of files to wait for. This is simply sent into self.add.
min_sizeminimum file size
min_mtime_ageminimum modification time age,
min_atime_ageminimum access time age.
min_ctime_agetime since last file status change (see stat(2))
min_fractionthe minimum fraction of the provided files that must match the above requirements in order for FileWaiter.wait to return True. Default is 1.0, which means all of them.

Definition at line 1042 of file fileop.py.

Member Function Documentation

def produtil.fileop.FileWaiter.add (   self,
  flist 
)

Adds a file, or iterable that iterates over files, to the list of files to wait for.

If the same filename is received a second time, it is ignored.

Parameters
flista filename (string) or list of filenames

Definition at line 1079 of file fileop.py.

Referenced by produtil.fileop.FileWaiter.add().

def produtil.fileop.FileWaiter.check (   self,
  filename,
  logger = None 
)

Checks to see if one file meets the requirements set in the constructor.

This default implementation calls check_file. This is in a separate member function so that a subclass can override the file checking method.

Returns
True if the file is "ready," and False if it is not.
Parameters
filenamethe path to the file to check
loggera logging.Logger for messages

Definition at line 1092 of file fileop.py.

Referenced by produtil.fileop.FileWaiter.checkfiles().

def produtil.fileop.FileWaiter.checkfiles (   self,
  maxwait = 1800,
  sleeptime = 20,
  logger = None,
  log_each_file = True 
)

Looks for the requested files.

Will loop, checking over and over up to maxwait seconds, sleeping sleeptime seconds between checks.

Parameters
maxwaitmaximum seconds to wait
sleeptimesleep time in seconds between checks
loggera logging.Logger for messages
log_each_filelog messages about each file checked

Definition at line 1120 of file fileop.py.

Referenced by produtil.fileop.FileWaiter.countmissing().

def produtil.fileop.FileWaiter.countfound (   self)

Returns the number of files that were found.

Definition at line 1112 of file fileop.py.

def produtil.fileop.FileWaiter.countmissing (   self)

Returns the number of files that were NOT found.

Definition at line 1115 of file fileop.py.

def produtil.fileop.FileWaiter.iterfound (   self)

Iterates over all files that were found.

Definition at line 1108 of file fileop.py.

def produtil.fileop.FileWaiter.reset (   self)

Resets internal information about which files have been seen.

Definition at line 1103 of file fileop.py.


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