Package schrodinger :: Package utils :: Module subprocess
[hide private]
[frames] | no frames]

Module subprocess

A wrapper to the standard library subprocess module.

This module automatically checks for executables in the $SCHRODINGER and $SCHRODINGER/utilities to make it absolute, and adds an interpreter to the command where appropriate.

A general limitation of this module is that the subprocess commands must be specified as lists of strings. This is a conscious design decision meant to avoid issues with quoting arguments that contain spaces.

Copyright Schrodinger, LLC. All rights reserved.

Functions [hide private]
 
_fix_call_cmd(cmd)
If the program name isn't an absolute path, look for the program in the $SCHRODINGER and $SCHRODINGER/utilities directories.
 
_wrap_command(subprocess_function, cmd, **kwargs)
int
call(cmd, **kwargs)
Run a command with arguments and wait for it to return.
int
check_call(cmd, **kwargs)
Run a command with arguments and wait for it to return.
str
check_output(cmd, **kwargs)
Run a command with arguments and wait for it to return.
 
Popen(cmd, **kwargs)
A wrapper for the builtin subprocess module's Popen class.
Variables [hide private]
  __doc__ = ...
  __package__ = None
hash(x)
Function Details [hide private]

_fix_call_cmd(cmd)

 

If the program name isn't an absolute path, look for the program in the $SCHRODINGER and $SCHRODINGER/utilities directories.

If the program executable has .pl or .py or .sh extension, and the appropriate interpreter is not specified, 'perl', 'python' or 'sh' interpreter is added for .pl, .py, .sh extension respectively.

Return a list of command line arguments that can be used to launch the command.

Parameters:
  • cmd (list of str) - The command to be run, specified as a list of strings.

call(cmd, **kwargs)

 

Run a command with arguments and wait for it to return. Return the exit status.

Look for executables in $SCHRODINGER and $SCHRODINGER/utilities, and provide an interpreter if needed.

Parameters:
  • cmd (list of str) - The command to be run, specified as a list of strings.
Returns: int
Exit status of the command.

check_call(cmd, **kwargs)

 

Run a command with arguments and wait for it to return. Raises an exception if the command exits with a non-zero exit status. Return the exit status.

Look for executables in $SCHRODINGER and $SCHRODINGER/utilities, and provide an interpreter if needed.

Parameters:
  • cmd (list of str) - The command to be run, specified as a list of strings.
Returns: int
Exit status of the command.
Raises:
  • subprocess.CalledProcessError - If the exit code is not 0.

check_output(cmd, **kwargs)

 

Run a command with arguments and wait for it to return. Raises an exception if the command exits with a non-zero exit status. Return the

Look for executables in $SCHRODINGER and $SCHRODINGER/utilities, and provide an interpreter if needed.

Parameters:
  • cmd (list of str) - The command to be run, specified as a list of strings.
Returns: str
StdOut of the command.
Raises:
  • subprocess.CalledProcessError - If the exit code is not 0.

Popen(cmd, **kwargs)

 

A wrapper for the builtin subprocess module's Popen class. This function will return a subprocess Popen instance, passing all kwargs on to the underlying class.

The only difference is that it will automatically look for executables in $SCHRODINGER and $SCHRODINGER/utilities, and provide an interpreter if needed.

Parameters:
  • cmd (list of str) - The command to be run, specified as a list of strings.

Variables Details [hide private]

__doc__

Value:
"""
A wrapper to the standard library subprocess module.

This module automatically checks for executables in the $SCHRODINGER
and $SCHRODINGER/utilities to make it absolute, and adds an interprete\
r to the
command where appropriate.

...