fdroidserver.tail module

Python-Tail - Unix tail follow implementation in Python.

python-tail can be used to monitor changes to a file.

Example

>>> import tail
>>>
>>> # Create a tail instance
>>> t = tail.Tail('file-to-be-followed')
>>>
>>> # Register a callback function to be called when a new line is found in the followed file.
>>> # If no callback function is registerd, new lines would be printed to standard out.
>>> t.register_callback(callback_function)
>>>
>>> # Follow the file with 5 seconds as sleep time between iterations.
>>> # If sleep time is not provided 1 second is used as the default time.
>>> t.follow(s=5)
class fdroidserver.tail.Tail(tailed_file)

Bases: object

Represents a tail command.

Methods

check_file_validity(file_)

Check whether the a given file exists, readable and is a file.

follow([s])

Do a tail follow.

register_callback(func)

Override default callback function to provided function.

start([s])

Start tailing a file in a background thread.

stop()

Stop a background tail.

check_file_validity(file_)

Check whether the a given file exists, readable and is a file.

follow(s=1)

Do a tail follow.

If a callback function is registered it is called with every new line. Else printed to standard out.

Parameters:
s

Number of seconds to wait between each iteration; Defaults to 1.

register_callback(func)

Override default callback function to provided function.

start(s=1)

Start tailing a file in a background thread.

Parameters:
s

Number of seconds to wait between each iteration; Defaults to 3.

stop()

Stop a background tail.

exception fdroidserver.tail.TailError(msg)

Bases: Exception