pysys.process.commonwrapper module¶
-
class
pysys.process.commonwrapper.
CommonProcessWrapper
(command, arguments, environs, workingDir, state, timeout, stdout=None, stderr=None, displayName=None)[source]¶ Bases:
object
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.
Variables: - pid (integer) – The process id for a running or complete process (as set by the OS)
- exitStatus (integer) – The process exit status for a completed process
-
__init__
(command, arguments, environs, workingDir, state, timeout, stdout=None, stderr=None, displayName=None)[source]¶ 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
orpysys.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
-
running
()[source]¶ Check to see if a process is running, returning true if running.
Returns: The running status (True / False) Return type: integer
-
start
()[source]¶ 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)
-
wait
(timeout)[source]¶ 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: ProcessTimeout – Raised if the timeout is exceeded.
-
write
(data, addNewLine=True)[source]¶ Write binary 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 stdin. As only binary data can be written to a process stdin, if a character string rather than a byte object is passed as the data, it will be automatically converted to a bytes object using the encoding given by locale.getpreferredencoding.
- addNewLine – True if a new line character is to be added to the end of the data string