User Tools

Site Tools


DzProcess

A class for starting/communicating with external programs.

More...

Inherits :

Enumerations

Properties

Constructors

DAZ Script
DzProcess ()
DzProcess ( Array args )
DzProcess ( String arg0 )

Methods

Signals

Detailed Description

See Also:

Enumerations


: Communication

Defines the communication channels connected to the process.

  • Stdin - Data can be written to the process' standard input.
  • Stdout - Data can be read from the process' standard output.
  • Stderr - Data can be read from the process' standard error.
  • DupStderr - Both, the process' standard error and its standard output are written to its standard output (which means nothing is sent to its standard error).

Properties


Array : arguments

Holds an Array of strings. The first being the program to execute, the rest being the command line arguments.


Communication : communication

Holds the communication for the process.


Number : exitStatus

Holds the exit status of the program when it has finished. 0 if the process is still running. (Read Only)


Boolean : normalExit

Holds whether or not the process has exited normally. (Read Only)


Boolean : running

Holds whether or not the process is currently running. (Read Only)


String : workingDirectory

Holds the working directory for the process.

Constructors


DzProcess()

Default Constructor.

Creates a DzProcess object without specifying the program or arguments.

Attention:

  • This does NOT start the process.

DzProcess( Array args )

Creates a DzProcess object specifying the program and any arguments.

Parameter(s):

  • args - The first element is the program to execute, the rest are the command line arguments.

Attention:

  • This does NOT start the process.

DzProcess( String arg0 )

Creates a DzProcess object specifying only the program, without any arguments.

Parameter(s):

  • arg0 - The command to be executed.

Attention:

  • This does NOT start the process.

Methods


Boolean : canReadLineStderr()

Return Value:

  • true if it is possible to read an entire line of text from standard error, otherwise false.

Boolean : canReadLineStdout()

Return Value:

  • true if it is possible to read an entire line of text from standard output, otherwise false.

void : closeStdin()

Closes the process' standard input and deletes any pending data that has not been written to standard input.


void : kill()

Terminates the process.

Attention:

  • This is not a safe way to end a process, as the process will not be able to perform any cleanup. tryTerminate() is safer, but process' can ignore it.

Boolean : launch( String buffer, Array env=[] )

Attempts to run the process, writing buffer to the process' standard input. Standard input is closed if all of the data in buffer is written to it.

Parameter(s):

  • buffer - The buffer to write to standard input with writeToStdin() using the local 8-bit representation of the string.
  • env - The environment settings (if any), to set. If non-empty, values are expected to be in the form “NAME=VALUE”, and the process is started with these environment settings. If empty (default), the process is started with the same environment settings as the starting process.

Return Value:

  • true if the process was able to start, otherwise false.

String : readLineStderr()

Return Value:

  • A line of text from standard error, minus any trailing newline or carriage return characters if canReadLineStderr() is true, otherwise an empty string.

String : readLineStdout()

Return Value:

  • A line of text from standard output, minus any trailing newline or carriage return characters if canReadLineStdout() is true, otherwise an empty string.

String : readStderr()

Reads the data that the process has written to standard error. When new data is written, the readyReadStderr() signal is emitted.

Return Value:

  • The data written to standard error, or an empty string if there is no such data.

Attention:

  • This method does not wait for there to be something to read.

String : readStdout()

Reads the data that the process has written to standard output. When new data is written, the readyReadStdout() signal is emitted.

Return Value:

  • The data written to standard output, or an empty string if there is no such data.

Attention:

  • This method does not wait for there to be something to read.

Boolean : start( Array env=[] )

Attempts to run the process for the program and arguments specified with the arguments property or as specified in the constructor.

Parameter(s):

  • env - The environment settings (if any), to set. If non-empty, values are expected to be in the form “NAME=VALUE”, and the process is started with these environment settings. If empty (default), the process is started with the same environment settings as the starting process.

Return Value:

  • true if the process was able to start, otherwise false.

void : tryTerminate()

Attempts to terminate the process.

Attention:

  • Process' can ignore this, if they choose to. If you want to be certain that the process is terminated, use kill() instead.

void : writeToStdin( String buffer )

Writes buffer to standard input. The process may, or may not, read the data. The wroteToStdin() signal is emitted once all data in buffer has been written to the process.

Parameter(s):

  • buffer - The buffer to write to.

Signals


void : launchFinished()

Signature:“launchFinished()”

Emitted when the process is started with launch(). If starting the process is successful, this signal is emitted after the data passed in has been written to standard input. If starting the process fails, this signal is emitted immediately.


void : processExited()

Signature:“processExited()”

Emitted when the process has exited.


void : readyReadStderr()

Signature:“readyReadStderr()”

Emitted when the process has written data to standard error.


void : readyReadStdout()

Signature:“readyReadStdout()”

Emitted when the process has written data to standard output.


void : wroteToStdin()

Signature:“wroteToStdin()”

Emitted if the data sent to standard input (via writeToStdin()) was actually written to the process.