Muster Renderclient Python API
The Muster Renderclient Python API is available under the MInstanceAPI module. It can be imported into Python by simply typing:
import MInstanceAPI
Be aware that , even you can import the MInstanceAPI module inside any Python script, it will work only inside the Muster builtin Python interpreter and just on the scripts of template functions that are directly invoked by the Renderclient service. You can still import it widely inside any template, but an attempt to call a function of the Renderclient from a wrong context, will return an error
A selective way to import modules only when launched from the correct context requires using the builtin muster.runningContext() function call like in the following example:
if (muster.runningContext() == "console"): import MConsoleAPI elif (muster.runningContext() == "dispatcher"): import MDispatcherAPI elif (muster.runningContext() == "renderclient"): import MInstanceAPI elif (muster.runningContext() == "notificator"): import MNotificatorAPI
Return types
Any function exported by the MInstanceAPI Python module returns always a MUSTERERR object as first. Each time you invoke a function, you must always check against the MUSTERERR object to check if the function has been invoked successfully.
In addition, the function may return a tuple instead of a single object with additional objects. Refer to each function specific documentation for a list of the returned objects:
import MInstanceAPI err,numOfInstances = MInstanceAPI.getRunningInstances()
Execution contexts
The family of the MInstanceAPI functions can be invoked from within the following contexts:
- A Console script that targets an instance execution context
- onClientIdling()
- onBuildCommandLine()
- onBuildAdditionalParameters()
- onGetApplicationPath()
- onGetApplicationStartingFolder()
- onBuildEnvironment()
- onGetWindowsBatFile()
- onCheckForSubframeAdvancingString()
- onCheckForFramesPrefixString()
- onCheckForFramesMask()
- onCheckForSubframeProgress()
- onCheckLogLine()
- onCheckLog()
- onCheckExitCode()
- onDetectRunningProcess()
- onStartProcess()
- onCollectProcessOutput()
- onTerminateProcess()
- onChangeProcessPriority()
- onCheckProcessTermination()
- onInstanceOverrideImpersonationUser()
- onCheckClientAvailability()
- onChunkStart()
- onChunkEnd()
Instance APIs
Function name | Expected parameters | Additional returned objects | Meaning |
---|---|---|---|
getRunningInstances() | None | number of running instances | Returns the number of the running instances on the node |
example | |||
getInstanceStatus(num) | Instance number | Status of the instance | Returns the current status of the specified instance |
example | |||
getRunningJobPid(num) | Instance number | integer | Returns an integer with the PID of the running job |
getRunningJob(num) | Instance number | an MJob object | Returns the job currently running on the instance as an MJob object |
getRunningChunk(num) | Instance number | an MChunk object | Returns the chunk currently running on the instance as an MChunk object |
example | |||
forceInstanceStatusUpdate(num) | Instance number | None | Forces a status update of the instance on the Dispatcher |
example | |||
setProcessPriority(num,priority) | Instance number, process priority | None | Sets the current process priority on the specified instance |
example | |||
pauseInstance(num) | Instance number | None | Pauses the specified instance |
example | |||
resumeInstance(num) | Instance number | None | Resumes the specified instance |
example | |||
killProcessAndPause(num) | Instance number | None | Kills the current process then pause the instance |
killProcessAndRedo(num) | Instance number | None | Kills the current process and restarts it |
killProcessAndGoOn(num) | Instance number | None | Kills the current process and go idle |
example | |||
enableRealtimeLog(num) | Instance number | None | Enables the realtime log on the instance |
disableRealtimeLog(num) | Instance number | None | Disables the realtime log on the instance |
example | |||
getConfiguration(config) | None | None | Retrieves the current node configuration |
setConfiguration(config,store) | MNodeConfiguration object, and a flag to store the configuration permanently | None | Sets the current node configuration |
softRestart() | None | None | Soft-restart the renderclient |
example | |||
sendMessage(instanceNum,templateId,message) | The instance number to send from, a target template ID and the message | None | Sends a custom message to the Dispatcher, it can be received into the target and the global template using onCustomNodeMessage(nodeId,message) , available since 8.5.3 |
example |