pyworkflow.utils.remote module

This modules contains some wrappers over the ssh paramiko library to provide handling functions on remote hosts through ssh.

Main classes are:

RemotePath: this class use an ssh/sftp connection to mimic the
functions in utils.path but remotely and provides basic file transfer
class pyworkflow.utils.remote.RemotePath(ssh)[source]

Bases: object

This class will server as a Wrapper to the paramiko sftp protocol througth a ssh connection. This class will implement useful methods for remote path handling such as: creating files, deleting folders…


Same as pyworkflow.utils.path.cleanPath but for remote folders or files.


Close both ssh and sftp connections.

copyTree(localFolder, remoteFolder)[source]

Same as shutil.copytree, but allowing that the dest folder also exists. dest is a remote folder.


Check if a remote path exists(like os.path.exists remotely).

classmethod fromCredentials(hostName, userName, password, port=22, **args)[source]
getFile(remoteFile, localFile)[source]

Wrapper around sftp.get that ensures path exists for localFile.


Check if a remote path is a directory (like os.path.isdir remotely).


Create the remote folder path for remoteFiles.


Make all path in remoteFolders list.


Like os.makedirs remotely.

putFile(localFile, remoteFile)[source]

Wrapper around sftp.put that ensures the remote path exists for put the file.

pyworkflow.utils.remote.sshConnect(hostName, userName, password, port=22, **args)[source]

Common way to create a ssh connection. Params:

hostName: Remote host name. userName: User name. password: Password. port: port to establish connection (usually 22)

Returns: ssh connection handler.


Establish a connection receiving a HostConfig class.


Test the connection to a remote host give its configuration.(see HostConfig class) Params:

host: configuration of the remote host, should contains hostName, userName and password.

Returns: True if the host could be reached.