shell_proc.py¶
-
exception
openmdao.util.shell_proc.
CalledProcessError
(returncode, cmd, errormsg)[source]¶ Bases:
subprocess.CalledProcessError
subprocess.CalledProcessError
plus errormsg attribute.
-
class
openmdao.util.shell_proc.
ShellProc
(args, stdin=None, stdout=None, stderr=None, env=None, universal_newlines=False)[source]¶ Bases:
subprocess.Popen
A slight modification to
subprocess.Popen
. If args is a string, then theshell
argument is set True. Updates a copy ofos.environ
with env and opens files for any stream which is astr
.- args: string or list
- If a string, then this is the command line to execute and the
subprocess.Popen
shell
argument is set True. Otherwise, this is a list of arguments; the first is the command to execute. - stdin, stdout, stderr: string, file, or int
- Specify handling of corresponding stream. If a string, a file
of that name is opened. Otherwise, see the
subprocess
documentation. - env: dict
- Environment variables for the command.
-
error_message
(return_code)[source]¶ Return error message for return_code. The error messages are derived from the operating system definitions. Some programs don’t necessarily return exit codes conforming to these definitions.
- return_code: int
- Return code from
poll()
.
-
terminate
(timeout=None)[source]¶ Stop child process. If timeout is specified, then
wait()
will be called to wait for the process to terminate.- timeout: float (seconds)
- Maximum time to wait for the process to stop. A value of zero implies an infinite maximum wait.
-
wait
(poll_delay=0.0, timeout=0.0)[source]¶ Polls for command completion or timeout. Closes any files implicitly opened. Returns
(return_code, error_msg)
.- poll_delay: float (seconds)
- Time to delay between polling for command completion. A value of zero uses an internal default.
- timeout: float (seconds)
- Maximum time to wait for command completion. A value of zero implies an infinite maximum wait.
-
openmdao.util.shell_proc.
call
(args, stdin=None, stdout=None, stderr=None, env=None, poll_delay=0.0, timeout=0.0)[source]¶ Run command with arguments. Returns
(return_code, error_msg)
.- args: string or list
- If a string, then this is the command line to execute and the
subprocess.Popen
shell
argument is set True. Otherwise, this is a list of arguments; the first is the command to execute. - stdin, stdout, stderr: string, file, or int
- Specify handling of corresponding stream. If a string, a file
of that name is opened. Otherwise, see the
subprocess
documentation. - env: dict
- Environment variables for the command.
- poll_delay: float (seconds)
- Time to delay between polling for command completion. A value of zero uses an internal default.
- timeout: float (seconds)
- Maximum time to wait for command completion. A value of zero implies an infinite maximum wait.
-
openmdao.util.shell_proc.
check_call
(args, stdin=None, stdout=None, stderr=None, env=None, poll_delay=0.0, timeout=0.0)[source]¶ Run command with arguments. If non-zero, return_code raises
CalledProcessError
.- args: string or list
- If a string, then this is the command line to execute, and the
subprocess.Popen
shell
argument is set True. Otherwise, this is a list of arguments; the first is the command to execute. - stdin, stdout, stderr: string, file, or int
- Specify handling of corresponding stream. If a string, a file
of that name is opened. Otherwise, see the
subprocess
documentation. - env: dict
- Environment variables for the command.
- poll_delay: float (seconds)
- Time to delay between polling for command completion. A value of zero uses an internal default.
- timeout: float (seconds)
- Maximum time to wait for command completion. A value of zero implies an infinite maximum wait.