schrodinger.job.remote_command module

exception schrodinger.job.remote_command.CommandError(sp_error=None, command='', errmsg=None, output='', userhost='', returncode=None)

Bases: Exception

Used to report external commands that fail.

When this is caught by the main cmdline driver, the error message will be printed and the usage message displayed.

__init__(sp_error=None, command='', errmsg=None, output='', userhost='', returncode=None)

The constructor takes a subprocess.CalledProcessError for the failed command, from which details of the command are extracted. A user- friendly error message will be composed from that information unless an explicit error message is provided.


Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

schrodinger.job.remote_command.which(program, search_path=None)

Search for a file in the given list of directories. Use $PATH if no search path is specified.

Returns the absolute pathname for the first executable found.


rogram – the executable to search for

Return type



the absolute pathname for the executable found, or None if the program could not be found.


Return the name of the rsh-compatible program to use for executing remote commands.

Return the pathname to a Bourne-compatible shell that can be used for running shell commands.

schrodinger.job.remote_command.remote_command(command, host, user=None, capture_stderr=False)

Execute a the given command on a particular host.

Returns a tuple containing the captured output and an error message.

  • host (string) – the host on which to run the command

  • user (string) – the user account under which to run the command

  • command (string) – the command to be executed on the remote machine

  • capture_stderr (boolean) – should stderr be captured along with stdout?

Return type



the captured output from the command


CommandError – if the remote command fails

schrodinger.job.remote_command.rsh_put_cmd(remotehost, put_fn, remoteuser=None, from_remote=False)

Returns the ‘scp’ command needed to execute to copy a file to a given remote host. The actual remote command needs to be appended to the returned string.

  • remotehost (string) – string

  • put_fn (string) – Path to the file that will be copied over. If it is a directory, it will be copied recursively

  • remoteuser (string) – Remote username

  • from_remote (bool) – If True, put from remote to local, otherwise (default) from local to remote

Return type



the list of command args for the command, suitable for use in subprocess functions

schrodinger.job.remote_command.get_remote_path(remoteuser, remotehost, path)

Assemble remote path from remote user, host and path.

  • remoteuser (str or None) – Remote user, can be None

  • remotehost (str) – Remote host

  • path (str) – Remote absolute path

Return type



Remote path with user and host


Test remote commands to and from one or more hosts.