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

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, jobs = MDispatcherAPI.jobGetList()
if (err.getErrorCode() != 0):
    print("Function failed: " + err.getDescription())
for job in jobs:
    print("Job status: " + str(job.getStatus()) + " name: " + job.getName()) 

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()
Function nameExpected parametersAdditional returned objectsMeaning
getRunningInstances()Nonenumber of running instancesReturns the number of the running instances on the node
getInstanceStatus(num)Instance numberStatus of the instanceReturns the current status of the specified instance
getRunningJob(num)Instance numberan MJob objectReturns the job currently running on the instance as an MJob object
getRunningChunk(num)Instance numberan MChunk objectReturns the chunk currently running on the instance as an MChunk object
forceInstanceStatusUpdate(num)Instance numberNoneForces a status update of the instance on the Dispatcher
setProcessPriority(num,priority)Instance number, process priorityNoneSets the current process priority on the specified instance
pauseInstance(num)Instance numberNonePauses the specified instance
resumeInstance(num)Instance numberNoneResumes the specified instance
killProcessAndPause(num)Instance numberNoneKills the current process then pause the instance
killProcessAndRedo(num)Instance numberNoneKills the current process and restarts it
killProcessAndGoOn(num)Instance numberNoneKills the current process and go idle
enableRealtimeLog(num)Instance numberNoneEnables the realtime log on the instance
disableRealtimeLog(num)Instance numberNoneDisables the realtime log on the instance
getConfiguration(config)NoneNoneRetrieves the current node configuration
setConfiguration(config,store)MNodeConfiguration object, and a flag to store the configuration permanentlyNoneSets the current node configuration
softRestart()NoneNoneSoft-restart the renderclient
sendMessage(instanceNum,templateId,message)The instance number to send from, a target template ID and the messageNoneSends a custom message to the Dispatcher, it can be received into the target or the global template using onCustomMessage(nodeId,message) , available since 8.5.3
  • muster/8.5/instanceapi.txt
  • Last modified: 2018/01/11 09:01
  • (external edit)