Class ProcessWrapper
source code
object --+
|
commonwrapper.CommonProcessWrapper --+
|
ProcessWrapper
Windows Process wrapper for process execution and management.
The process wrapper provides the ability to start and stop an external
process, setting the process environment, working directory and state
i.e. a foreground process in which case a call to the start method will not return until the process has
exited, or a background process in which case the process is started in a
separate thread allowing concurrent execution within the testcase.
Processes started in the foreground can have a timeout associated with
them, such that should the timeout be exceeded, the process will be
terminated and control passed back to the caller of the method. The
wrapper additionally allows control over logging of the process stdout
and stderr to file, and writing to the process stdin.
Usage of the class is to first create an instance, setting all runtime
parameters of the process as data attributes to the class instance via
the constructor. The process can then be started and stopped via the start and stop methods of the class, as well as interrogated for
its executing status via the running method, and waited for its completion via the wait method. During process execution the
self.pid
and seld.exitStatus
data attributes
are set within the class instance, and these values can be accessed
directly via it's object reference.
|
__init__(self,
command,
arguments,
environs,
workingDir,
state,
timeout,
stdout=None,
stderr=None,
displayName=None,
**kwargs)
Create an instance of the process wrapper. |
source code
|
|
|
__quotePath(self,
input)
Private method to sanitise a windows path. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
Inherited from commonwrapper.CommonProcessWrapper :
__repr__ ,
__str__ ,
running ,
start ,
wait ,
write
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
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)
|
Inherited from object :
__class__
|
__init__(self,
command,
arguments,
environs,
workingDir,
state,
timeout,
stdout=None,
stderr=None,
displayName=None,
**kwargs)
(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__
|
Send a signal to a running process.
Note that this method is not implemented for win32 processes, and
calling this on a win32 OS will raise a NotImplementedError.
- Parameters:
signal - The integer signal to send to the process
- Raises:
ProcessError - Raised if an error occurred whilst trying to signal the process
- Overrides:
commonwrapper.CommonProcessWrapper.signal
|