Package application :: Package dialogs :: Module FileTail :: Class Tail
[hide private]
[frames] | no frames]

Class Tail

source code

object --+
         |
        Tail

The Tail monitor object.

Instance Methods [hide private]
 
__init__(self, path, only_new=True, min_sleep=1, sleep_interval=1, max_sleep=60)
Initialize a tail monitor.
source code
 
_recompute_rate(self, n, start, stop)
Internal function for recomputing the sleep interval.
source code
 
_fill_cache(self)
Internal method for grabbing as much data out of the file as is available and caching it for future calls to nextline().
source code
 
_dequeue(self)
Internal method; returns the first available line out of the cache, if any.
source code
 
_reset(self)
Internal method; reopen the internal file handle (probably because the log file got rotated/truncated).
source code
 
nextline(self, callback=<Locale: en_US>)
Return the next line from the file.
source code
 
close(self)
Close the tail monitor, discarding any remaining input.
source code
 
__iter__(self)
Iterator interface, so you can do:...
source code
 
next(self)
Kick the iterator interface.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, path, only_new=True, min_sleep=1, sleep_interval=1, max_sleep=60)
(Constructor)

source code 
Initialize a tail monitor.
path: filename to open
only_new: By default, the tail monitor will start reading from
  the beginning of the file when first opened. Set only_new to
  True to have it skip to the end when it first opens, so that
  you only get the new additions that arrive after you start
  monitoring. 
min_sleep: Shortest interval in seconds to sleep when waiting
  for more input to arrive. Defaults to 1.0 second.
sleep_interval: The tail monitor will dynamically recompute an
  appropriate sleep interval based on a sliding window of data
  arrival rate. You can set sleep_interval here to seed it
  initially if the default of 1.0 second doesn't work for you
  and you don't want to wait for it to converge.
max_sleep: Maximum interval in seconds to sleep when waiting
  for more input to arrive. Also, if this many seconds have
  elapsed without getting any new data, the tail monitor will
  check to see if the log got truncated (rotated) and will
  quietly reopen itself if this was the case. Defaults to 60.0
  seconds.

Overrides: object.__init__

_recompute_rate(self, n, start, stop)

source code 
Internal function for recomputing the sleep interval. I get called with a number of lines that appeared between the start and stop times; this will get added to a sliding window, and I will recompute the average interarrival rate over the last window.

_fill_cache(self)

source code 
Internal method for grabbing as much data out of the file as is available and caching it for future calls to nextline(). Returns the number of lines just read.

nextline(self, callback=<Locale: en_US>)

source code 
Return the next line from the file. Blocks if there are no lines immediately available.

__iter__(self)

source code 
Iterator interface, so you can do:

for line in filetail.Tail('log.txt'):
    # do stuff
    pass

next(self)

source code 
Kick the iterator interface. Used under the covers to support:

for line in filetail.Tail('log.txt'):
    # do stuff
    pass