PyFoam.Infrastructure.FoamServer module¶
A XMLRPC-Server that answeres about the current state of a Foam-Run
-
class
PyFoam.Infrastructure.FoamServer.
FoamAnswerer
(run=None, master=None, lines=100, foamserver=None)[source]¶ Bases:
object
The class that handles the actual requests (only needed to hide the Thread-methods from the world
-
__dict__
= mappingproxy({'tail': <function FoamAnswerer.tail>, 'createTime': <function FoamAnswerer.createTime>, '__init__': <function FoamAnswerer.__init__>, 'elapsedTime': <function FoamAnswerer.elapsedTime>, 'getDictionaryContents': <function FoamAnswerer.getDictionaryContents>, 'lastLine': <function FoamAnswerer.lastLine>, '__module__': 'PyFoam.Infrastructure.FoamServer', 'foamVersion': <function FoamAnswerer.foamVersion>, 'nrWarnings': <function FoamAnswerer.nrWarnings>, 'ip': <function FoamAnswerer.ip>, 'startTime': <function FoamAnswerer.startTime>, 'lastLogLineSeen': <function FoamAnswerer.lastLogLineSeen>, 'time': <function FoamAnswerer.time>, 'uname': <function FoamAnswerer.uname>, 'startTimestamp': <function FoamAnswerer.startTimestamp>, 'getPlotData': <function FoamAnswerer.getPlotData>, 'hostname': <function FoamAnswerer.hostname>, 'solutionFiles': <function FoamAnswerer.solutionFiles>, 'pid': <function FoamAnswerer.pid>, 'commandLine': <function FoamAnswerer.commandLine>, 'id': <function FoamAnswerer.id>, 'mpi': <function FoamAnswerer.mpi>, '_insertLine': <function FoamAnswerer._insertLine>, 'getEnviron': <function FoamAnswerer.getEnviron>, 'isLiving': <function FoamAnswerer.isLiving>, '__dict__': <attribute '__dict__' of 'FoamAnswerer' objects>, 'getPlots': <function FoamAnswerer.getPlots>, 'argv': <function FoamAnswerer.argv>, 'writtenTimesteps': <function FoamAnswerer.writtenTimesteps>, 'getRemark': <function FoamAnswerer.getRemark>, '__weakref__': <attribute '__weakref__' of 'FoamAnswerer' objects>, 'controlDictUnmodified': <function FoamAnswerer.controlDictUnmodified>, 'setRemark': <function FoamAnswerer.setRemark>, 'writeDictionaryContents': <function FoamAnswerer.writeDictionaryContents>, 'write': <function FoamAnswerer.write>, 'procNr': <function FoamAnswerer.procNr>, 'configuration': <function FoamAnswerer.configuration>, 'jobId': <function FoamAnswerer.jobId>, 'writeDictionaryText': <function FoamAnswerer.writeDictionaryText>, 'cwd': <function FoamAnswerer.cwd>, '_kill': <function FoamAnswerer._kill>, 'runnerData': <function FoamAnswerer.runnerData>, 'lastTimeStepSeen': <function FoamAnswerer.lastTimeStepSeen>, 'deltaT': <function FoamAnswerer.deltaT>, 'user': <function FoamAnswerer.user>, 'getDictionaryText': <function FoamAnswerer.getDictionaryText>, '__doc__': 'The class that handles the actual requests (only needed to hide the\n Thread-methods from the world\n ', 'isParallel': <function FoamAnswerer.isParallel>, 'scriptName': <function FoamAnswerer.scriptName>, 'usedArgv': <function FoamAnswerer.usedArgv>, 'stop': <function FoamAnswerer.stop>, '_readParameter': <function FoamAnswerer._readParameter>, 'listFiles': <function FoamAnswerer.listFiles>, 'isFoamServer': <function FoamAnswerer.isFoamServer>, 'pathToSolution': <function FoamAnswerer.pathToSolution>, 'endTime': <function FoamAnswerer.endTime>, 'loadAvg': <function FoamAnswerer.loadAvg>, 'pyFoamVersion': <function FoamAnswerer.pyFoamVersion>, 'actualCommandLine': <function FoamAnswerer.actualCommandLine>})¶
-
__init__
(run=None, master=None, lines=100, foamserver=None)[source]¶ Parameters: - run – The thread that controls the run
- master – The Runner-Object that controls everything
- lines – the number of lines the server should remember
-
__module__
= 'PyFoam.Infrastructure.FoamServer'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_readParameter
(name)[source]¶ Reads a parametr from the controlDict :param name: the parameter :return: The value
-
getDictionaryContents
(directory, name)[source]¶ Parameters: - directory – Sub-directory of the case
- name – name of the dictionary file
Returns: the contents of the file as a python data-structure
-
getDictionaryText
(directory, name)[source]¶ Parameters: - directory – Sub-directory of the case
- name – name of the dictionary file
Returns: the contents of the file as a big string
-
getEnviron
(name)[source]¶ Parameters: name – name of an environment variable Returns: value of the variable, empty string if non-existing
-
listFiles
(directory)[source]¶ Parameters: directory – Sub-directory of the case Returns: List of the filenames (not directories) in that case
-
setRemark
(remark)[source]¶ Overwrite the user-defined remark :return: True if the remark was set previously
-
solutionFiles
(time)[source]¶ Parameters: time – name of the timestep Returns: list of the solution files at that timestep
-
writeDictionaryContents
(directory, name, contents)[source]¶ Writes the contents of a dictionary :param directory: Sub-directory of the case :param name: name of the dictionary file :param contents: Python-dictionary with the dictionary contents
-
-
class
PyFoam.Infrastructure.FoamServer.
FoamServer
(run=None, master=None, lines=100)[source]¶ Bases:
threading.Thread
This is the class that serves the requests about the FOAM-Run
-
__init__
(run=None, master=None, lines=100)[source]¶ Parameters: - run – The thread that controls the run
- master – The Runner-Object that controls everything
- lines – the number of lines the server should remember
-
__module__
= 'PyFoam.Infrastructure.FoamServer'¶
-
-
PyFoam.Infrastructure.FoamServer.
findFreePort
()[source]¶ Finds a free server port on this machine and returns it
Valid server ports are in the range 18000 upward (the function tries to find the lowest possible port number
ATTENTION: this part may introduce race conditions
-
PyFoam.Infrastructure.FoamServer.
random
() → x in the interval [0, 1).¶