@(@\newcommand{\B}[1]{ {\bf #1} }
\newcommand{\R}[1]{ {\rm #1} }
\newcommand{\W}[1]{ \; #1 \; }@)@
This is dismod_at-20221105 documentation: Here is a link to its
current documentation
.
Purpose
This routine provides variations on the following steps:
Print the system command as it would appear in the shell; i.e.,
with arguments separated by spaces.
Run the system command and wait for it to complete.
Check the integer value returned by the system command.
If it is non-zero, an assert exception is raised with
stderr as the message in the exception.
Return the contents of standard out as a python string.
command
is a list with str elements. The first element is the
program to execute and the other elements are arguments to the program.
print_command
If this argument is true (false) the command will (will not) be printed
before it is executed.
return_stdout
If this argument is true, the command's standard output will be returned.
If this argument is false and
file_stdout
is not None,
standard error will be written to a file during the command execution.
Otherwise, standard output will be printed during the command execution.
return_stderr
If this argument is true, the command's standard error will be returned.
If this argument is false and
file_stderr
is not None,
standard error will be written to a file during the command execution.
Otherwise, if an error occurs, an assertion is generated with
the commands standard error as the corresponding message.
file_stdout
If
return_stdout
is true, this argument must be None.
If this argument is not None, it is a file object that is opened for writing
and standard output will be written to this file.
file_stderr
If
return_stderr
is true, this argument must be None.
If this argument is not None, it is a file object that is opened for writing
and standard error will be written to this file.
write_command
If
write_command
is true (false) the command will
(will not) be written to
file_stdout
.
If
file_stdout
is None,
write_command
must be false.
If
return_stdout
and
return stderr
are both false,
result
is None.
If
return_stdout
is true and
return_stderr
is false,
result
is a str with the contents of standard output.
If
return_stderr
is true and
return_stdout
is false,
result.stderr
is an str with the contents of standard error,
and
result.returncode
is an int with the command's return code..
If both
return_stderr
and
return_stdout
are true,
result.stderr
is an str with the contents of standard error,
result.stdout
is an str with the contents of standard output,
and
result.returncode
is an int with the command's return code..
Example
Many of the user_example
examples use this utility.
Input File: python/dismod_at/system_command_prc.py