Package pysys :: Package process :: Module commonwrapper :: Class CommonProcessWrapper
[hide private]
[frames] | no frames]

Class CommonProcessWrapper

source code

object --+
         |
        CommonProcessWrapper
Known Subclasses:

Abstract base process wrapper class for process execution and management.

A base implementation of common process related operations, which should be extended by the OS specific wrapper classes.

Instance Methods [hide private]
 
__init__(self, command, arguments, environs, workingDir, state, timeout, stdout=None, stderr=None, displayName=None)
Create an instance of the process wrapper.
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
setExitStatus(self) source code
 
startBackgroundProcess(self) source code
 
writeStdin(self) source code
 
stop(self) source code
 
signal(self) source code
 
write(self, data, addNewLine=True)
Write data to the stdin of the process.
source code
integer
running(self)
Check to see if a process is running, returning true if running.
source code
 
wait(self, timeout)
Wait for a process to complete execution.
source code
 
start(self)
Start a process using the runtime parameters set at instantiation.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Instance Variables [hide private]
integer exitStatus
The process exit status for a completed process
integer pid
The process id for a running or complete process (as set by the OS)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, command, arguments, environs, workingDir, state, timeout, stdout=None, stderr=None, displayName=None)
(Constructor)

source code 

Create an instance of the process wrapper.

Parameters:
  • command - The full path to the command to execute
  • arguments - A list of arguments to the command
  • environs - A dictionary of environment variables (key, value) for the process context execution
  • workingDir - The working directory for the process
  • state - The state of the process (pysys.constants.FOREGROUND or pysys.constants.BACKGROUND
  • timeout - The timeout in seconds to be applied to the process
  • stdout - The full path to the filename to write the stdout of the process
  • stderr - The full path to the filename to write the sdterr of the process
  • displayName - Display name for this process
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

write(self, data, addNewLine=True)

source code 

Write data to the stdin of the process.

Note that when the addNewLine argument is set to true, if a new line does not terminate the input data string, a newline character will be added. If one already exists a new line character will not be added. Should you explicitly require to add data without the method appending a new line charater set addNewLine to false.

Parameters:
  • data - The data to write to the process stdout
  • addNewLine - True if a new line character is to be added to the end of the data string

running(self)

source code 

Check to see if a process is running, returning true if running.

Returns: integer
The running status (True / False)

wait(self, timeout)

source code 

Wait for a process to complete execution.

The method will block until either the process is no longer running, or the timeout is exceeded. Note that the method will not terminate the process if the timeout is exceeded.

Parameters:
  • timeout - The timeout to wait in seconds. Always provide a timeout, otherwise your test may block indefinitely!
Raises:

start(self)

source code 

Start a process using the runtime parameters set at instantiation.

Raises:
  • ProcessError - Raised if there is an error creating the process
  • ProcessTimeout - Raised in the process timed out (foreground process only)