MeVisLab Scripting Reference
MLABProcess Class Reference

Inherits QProcess, and QObject.

Inherited by MLABOutputDiscardingProcess, and MLABOutputRecordingProcess.

Public Slots

Script access


void addArgument (const QString &arg)
 
void addArguments (const QStringList &args)
 
void clearArguments ()
 
void setArgs (const QString &cmd, const QString &args)
 
void setWorkDir (const QString &wd)
 
void setStdOutHandler (MLABModule *mod, const QString &script)
 
void setStdErrHandler (MLABModule *mod, const QString &script)
 
void setExitedHandler (MLABModule *mod, const QString &script)
 
void setLaunchFinishedHandler (MLABModule *mod, const QString &script)
 
bool run (const QString &stdinput)
 
bool run ()
 
void waitForLaunch ()
 
void waitForExit ()
 
bool normalExit ()
 
bool isRunning ()
 
bool launchFinished ()
 
void setUserInfo (const QString &info)
 
QString userInfo ()
 
QString readStdOut ()
 
QString readStdErr ()
 
QString readLineStdOut ()
 
QString readLineStdErr ()
 
int exitStatus ()
 
void kill ()
 
qint64 processId ()
 
void setInheritHandles (bool inherit)
 
bool doesInheritHandles () const
 

Detailed Description

MLABProcess object available via MLAB.

The MLABProcess object can be used to have full control of started processes. For simpler functions, see MLAB API.

Note that the process object behaves differently on different platforms!

binary = MLABFileManager.getExecutable("MeVisLab")
p.addArgument(binary)
p.setLaunchFinishedHandler(ctx, "launchFinished")
p.setExitedHandler(ctx, "exited")
p.setStdOutHandler(ctx, "stdOut")
p.setStdErrHandler(ctx, "stdErr")
p.run()
Global MLABFileManager object available in all scripts.
Definition: mlabScriptWrappers.h:244
QString getExecutable(const QString &name)
Returns the absolute path of the given executable (where name is given without debug and file extensi...
Access to all global functions and objects of MeVisLab (MLAB).
Definition: mlabGlobalScriptAccess.h:81
MLABProcess * newProcess()
Creates a new process, see MLABProcess class for its API.
// Example handler:
def stdOut(p):
QString readLineStdOut()
Returns one line of std output.

Member Function Documentation

◆ addArgument

void MLABProcess::addArgument ( const QString &  arg)
slot

Adds an argument, first argument added is the called program.

◆ addArguments

void MLABProcess::addArguments ( const QStringList &  args)
slot

Adds an argument list, first argument is the called program.

◆ clearArguments

void MLABProcess::clearArguments ( )
slot

Clears the arguments.

◆ doesInheritHandles

bool MLABProcess::doesInheritHandles ( ) const
inlineslot

Returns whether the process should inherit all file handles of the parent process.

◆ exitStatus

int MLABProcess::exitStatus ( )
inlineslot

Returns the exit status of the process.

◆ isRunning

bool MLABProcess::isRunning ( )
slot

Returns whether the process is currently running.

◆ kill

void MLABProcess::kill ( )
inlineslot

Kills the running process (more than just deleting the MLABProcess, it really kills the running process!).

◆ launchFinished

bool MLABProcess::launchFinished ( )
inlineslot

Returns whether the launch is finished (it is safe to delete the process afterwards).

◆ normalExit

bool MLABProcess::normalExit ( )
slot

Returns whether the process exited normally, i.e., did not crash.

◆ processId

qint64 MLABProcess::processId ( )
inlineslot

Returns the process ID of the process.

◆ readLineStdErr

QString MLABProcess::readLineStdErr ( )
slot

Returns one line of error output.

◆ readLineStdOut

QString MLABProcess::readLineStdOut ( )
slot

Returns one line of std output.

◆ readStdErr

QString MLABProcess::readStdErr ( )
slot

Returns the whole error output currently available, does not return the same output a second time!

◆ readStdOut

QString MLABProcess::readStdOut ( )
slot

Returns the whole std output currently available, does not return the same output a second time!

◆ run [1/2]

bool MLABProcess::run ( )
slot

Runs the process.

◆ run [2/2]

bool MLABProcess::run ( const QString &  stdinput)
slot

Runs the process with given std input.

Note
On Windows, the process will automatically be set to inherit file handles, since otherwise, the input cannot be passed to the process.

◆ setArgs

void MLABProcess::setArgs ( const QString &  cmd,
const QString &  args 
)
slot

Sets the command and the arguments.

Arguments are split by spaces, so this format does not support argument entries that contain spaces. Use the addArguments() method instead.

◆ setExitedHandler

void MLABProcess::setExitedHandler ( MLABModule mod,
const QString &  script 
)
slot

Sets a handler that is called when the process exited.

◆ setInheritHandles

void MLABProcess::setInheritHandles ( bool  inherit)
inlineslot

Sets whether the process should inherit all file handles of the parent process. Default is false.

◆ setLaunchFinishedHandler

void MLABProcess::setLaunchFinishedHandler ( MLABModule mod,
const QString &  script 
)
slot

Sets a handler that is called when the process launch (and stdin args passing) is complete.

◆ setStdErrHandler

void MLABProcess::setStdErrHandler ( MLABModule mod,
const QString &  script 
)
slot

Sets an error handler that is called when new output is available.

◆ setStdOutHandler

void MLABProcess::setStdOutHandler ( MLABModule mod,
const QString &  script 
)
slot

Sets a std output handler that is called when new output is available.

◆ setUserInfo

void MLABProcess::setUserInfo ( const QString &  info)
inlineslot

Sets user information for this process.

◆ setWorkDir

void MLABProcess::setWorkDir ( const QString &  wd)
slot

Sets the working directory.

◆ userInfo

QString MLABProcess::userInfo ( )
inlineslot

Returns user information for this process.

◆ waitForExit

void MLABProcess::waitForExit ( )
slot

Waits until the running process exits.

◆ waitForLaunch

void MLABProcess::waitForLaunch ( )
slot

Waits until the process is completely launched (before this, it is not safe to delete the process!).