PyFoam.Execution.BasicWatcher module

Watches the output of Foam-run

class PyFoam.Execution.BasicWatcher.BasicWatcher(filenames, silent=False, tailLength=1000, sleep=0.1, follow=True)[source]

Bases: object

Base class for watching the output of commands

Works like the UNIX-command ‘tail -f <file>’: the last lines of the file are output. If the file grows then these lines are output as they arrive

__dict__ = dict_proxy({'changeFile': <function changeFile>, 'getSize': <function getSize>, '__module__': 'PyFoam.Execution.BasicWatcher', 'lineHandle': <function lineHandle>, 'addChangeFileHook': <function addChangeFileHook>, 'startHandle': <function startHandle>, 'stopHandle': <function stopHandle>, 'start': <function start>, 'tailingHandle': <function tailingHandle>, '__dict__': <attribute '__dict__' of 'BasicWatcher' objects>, '__weakref__': <attribute '__weakref__' of 'BasicWatcher' objects>, '__doc__': "Base class for watching the output of commands\n\n Works like the UNIX-command 'tail -f <file>': the last lines of the file are output.\n If the file grows then these lines are output as they arrive", '__init__': <function __init__>})
__init__(filenames, silent=False, tailLength=1000, sleep=0.1, follow=True)[source]
Parameters:
  • filename – name of the logfile to watch
  • silent – if True no output is sent to stdout
  • tailLength – number of bytes at the end of the fail that should be output.
  • follow – if the end of the file is reached wait for further input

Because data is output on a per-line-basis :param sleep: interval to sleep if no line is returned

__module__ = 'PyFoam.Execution.BasicWatcher'
__weakref__

list of weak references to the object (if defined)

addChangeFileHook(func)[source]
changeFile(filename)[source]
getSize(filename)[source]
Returns:the current size (in bytes) of the file
lineHandle(line)[source]

called every time a new line is read

start()[source]

Reads the file and does the processing

startHandle()[source]

to be called before the program is started

stopHandle()[source]

called after the program has stopped

tailingHandle()[source]

called when the first line is output