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({'__module__': 'PyFoam.Infrastructure.FoamServer', '__doc__': 'The class that handles the actual requests (only needed to hide the\n Thread-methods from the world\n ', '__init__': <function FoamAnswerer.__init__>, '_insertLine': <function FoamAnswerer._insertLine>, 'isFoamServer': <function FoamAnswerer.isFoamServer>, 'isLiving': <function FoamAnswerer.isLiving>, '_kill': <function FoamAnswerer._kill>, 'stop': <function FoamAnswerer.stop>, 'stopAtNextWrite': <function FoamAnswerer.stopAtNextWrite>, 'write': <function FoamAnswerer.write>, 'argv': <function FoamAnswerer.argv>, 'usedArgv': <function FoamAnswerer.usedArgv>, 'isParallel': <function FoamAnswerer.isParallel>, 'procNr': <function FoamAnswerer.procNr>, 'nrWarnings': <function FoamAnswerer.nrWarnings>, 'commandLine': <function FoamAnswerer.commandLine>, 'actualCommandLine': <function FoamAnswerer.actualCommandLine>, 'scriptName': <function FoamAnswerer.scriptName>, 'runnerData': <function FoamAnswerer.runnerData>, 'lastLogLineSeen': <function FoamAnswerer.lastLogLineSeen>, 'lastTimeStepSeen': <function FoamAnswerer.lastTimeStepSeen>, 'lastLine': <function FoamAnswerer.lastLine>, 'tail': <function FoamAnswerer.tail>, 'elapsedTime': <function FoamAnswerer.elapsedTime>, 'getEnviron': <function FoamAnswerer.getEnviron>, 'mpi': <function FoamAnswerer.mpi>, 'foamVersion': <function FoamAnswerer.foamVersion>, 'pyFoamVersion': <function FoamAnswerer.pyFoamVersion>, 'uname': <function FoamAnswerer.uname>, 'ip': <function FoamAnswerer.ip>, 'hostname': <function FoamAnswerer.hostname>, 'configuration': <function FoamAnswerer.configuration>, 'cwd': <function FoamAnswerer.cwd>, 'pid': <function FoamAnswerer.pid>, 'loadAvg': <function FoamAnswerer.loadAvg>, 'user': <function FoamAnswerer.user>, 'id': <function FoamAnswerer.id>, 'startTimestamp': <function FoamAnswerer.startTimestamp>, 'time': <function FoamAnswerer.time>, 'createTime': <function FoamAnswerer.createTime>, '_readParameter': <function FoamAnswerer._readParameter>, 'startTime': <function FoamAnswerer.startTime>, 'endTime': <function FoamAnswerer.endTime>, 'deltaT': <function FoamAnswerer.deltaT>, 'pathToSolution': <function FoamAnswerer.pathToSolution>, 'writtenTimesteps': <function FoamAnswerer.writtenTimesteps>, 'solutionFiles': <function FoamAnswerer.solutionFiles>, 'listFiles': <function FoamAnswerer.listFiles>, 'getDictionaryText': <function FoamAnswerer.getDictionaryText>, 'getDictionaryContents': <function FoamAnswerer.getDictionaryContents>, 'writeDictionaryText': <function FoamAnswerer.writeDictionaryText>, 'writeDictionaryContents': <function FoamAnswerer.writeDictionaryContents>, 'getPlots': <function FoamAnswerer.getPlots>, 'getPlotData': <function FoamAnswerer.getPlotData>, 'controlDictUnmodified': <function FoamAnswerer.controlDictUnmodified>, 'getRemark': <function FoamAnswerer.getRemark>, 'setRemark': <function FoamAnswerer.setRemark>, 'jobId': <function FoamAnswerer.jobId>, '__dict__': <attribute '__dict__' of 'FoamAnswerer' objects>, '__weakref__': <attribute '__weakref__' of 'FoamAnswerer' objects>})¶
-
__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'¶
-
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
-
PyFoam.Infrastructure.FoamServer.
findFreePort
(useSSL=None)[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).¶