aiida.transports.plugins package#
Plugins for the transport.
Submodules#
Local transport
- class aiida.transports.plugins.local.LocalTransport(*args, **kwargs)[source]#
Bases:
Transport
Support copy and command execution on the same host on which AiiDA is running via direct file copy and execution commands.
Note that the environment variables are copied from the submitting process, so you might need to clean it with a
prepend_text
. For example, the AiiDA daemon sets aPYTHONPATH
, so you might want to addunset PYTHONPATH
if you plan on running calculations that use Python.- DEFAULT_MINIMUM_JOB_POLL_INTERVAL = 0.1#
- _DEFAULT_SAFE_OPEN_INTERVAL = 0.0#
- __abstractmethods__ = frozenset({})#
- __init__(*args, **kwargs)[source]#
__init__ method of the Transport base class.
- Parameters:
safe_interval – (optional, default self._DEFAULT_SAFE_OPEN_INTERVAL) Minimum time interval in seconds between opening new connections.
use_login_shell – (optional, default True) if False, do not use a login shell when executing command
- __module__ = 'aiida.transports.plugins.local'#
- _abc_impl = <_abc._abc_data object>#
- _exec_command_internal(command, **kwargs)[source]#
Executes the specified command in bash login shell.
Before the command is executed, changes directory to the current working directory as returned by self.getcwd().
For executing commands and waiting for them to finish, use exec_command_wait. Otherwise, to end the process, use the proc.wait() method.
The subprocess is set to have a different process group than the main process, so that it is shielded from signals sent to the parent.
- Parameters:
command – the command to execute. The command is assumed to be already escaped using
aiida.common.escaping.escape_for_bash()
.- Returns:
a tuple with (stdin, stdout, stderr, proc), where stdin, stdout and stderr behave as file-like objects, proc is the process object as returned by the subprocess.Popen() class.
- static _os_path_split_asunder(path)[source]#
Used by makedirs, Takes path (a str) and returns a list deconcatenating the path.
- chdir(path)[source]#
Changes directory to path, emulated internally. :param path: path to cd into :raise OSError: if the directory does not have read attributes.
- chmod(path, mode)[source]#
Changes permission bits of object at path :param path: path to modify :param mode: permission bits
- Raises:
OSError – if path does not exist.
- chown(path, uid, gid)[source]#
Change the owner (uid) and group (gid) of a file. As with python’s os.chown function, you must pass both arguments, so if you only want to change one, use stat first to retrieve the current owner and group.
- close()[source]#
Closes the local transport channel
- Raises:
aiida.common.InvalidOperation – if the channel is already open
- copy(remotesource, remotedestination, dereference=False, recursive=True)[source]#
Copies a file or a folder from ‘remote’ remotesource to ‘remote’ remotedestination. Automatically redirects to copyfile or copytree.
- Parameters:
remotesource – path to local file
remotedestination – path to remote file
dereference – follow symbolic links. Default = False
recursive (bool) – if True copy directories recursively, otherwise only copy the specified file(s)
- Raises:
ValueError – if ‘remote’ remotesource or remotedestinationis not valid
OSError – if remotesource does not exist
- copyfile(remotesource, remotedestination, dereference=False)[source]#
Copies a file from ‘remote’ remotesource to ‘remote’ remotedestination.
- Parameters:
remotesource – path to local file
remotedestination – path to remote file
dereference (bool) – if True copy the contents of any symlinks found, otherwise copy the symlinks themselves
- Raises:
ValueError – if ‘remote’ remotesource or remotedestination is not valid
OSError – if remotesource does not exist
- copytree(remotesource, remotedestination, dereference=False)[source]#
Copies a folder from ‘remote’ remotesource to ‘remote’ remotedestination.
- Parameters:
remotesource – path to local file
remotedestination – path to remote file
dereference – follow symbolic links. Default = False
- Raises:
ValueError – if ‘remote’ remotesource or remotedestination is not valid
OSError – if remotesource does not exist
- property curdir#
Returns the _internal_dir, if the channel is open. If possible, use getcwd() instead!
- exec_command_wait_bytes(command, stdin=None, **kwargs)[source]#
Executes the specified command and waits for it to finish.
- Parameters:
command – the command to execute
- Returns:
a tuple with (return_value, stdout, stderr) where stdout and stderr are both bytes and the return_value is an int.
- get(remotepath, localpath, *args, **kwargs)[source]#
Copies a folder or a file recursively from ‘remote’ remotepath to ‘local’ localpath. Automatically redirects to getfile or gettree.
- Parameters:
remotepath – path to local file
localpath – absolute path to remote file
dereference – follow symbolic links default = True
overwrite – if True overwrites localpath default = False
- Raises:
OSError – if ‘remote’ remotepath is not valid
ValueError – if ‘local’ localpath is not valid
- get_attribute(path)[source]#
Returns an object FileAttribute, as specified in aiida.transports. :param path: the path of the given file.
- getfile(remotepath, localpath, *args, **kwargs)[source]#
Copies a file recursively from ‘remote’ remotepath to ‘local’ localpath.
- Parameters:
remotepath – path to local file
localpath – absolute path to remote file
overwrite – if True overwrites localpath. Default = False
:raise OSError if ‘remote’ remotepath is not valid or not found :raise ValueError: if ‘local’ localpath is not valid :raise OSError: if unintentionally overwriting
- gettree(remotepath, localpath, *args, **kwargs)[source]#
Copies a folder recursively from ‘remote’ remotepath to ‘local’ localpath.
- Parameters:
remotepath – path to local file
localpath – absolute path to remote file
dereference – follow symbolic links. Default = True
overwrite – if True overwrites localpath. Default = False
- Raises:
OSError – if ‘remote’ remotepath is not valid
ValueError – if ‘local’ localpath is not valid
OSError – if unintentionally overwriting
- gotocomputer_command(remotedir)[source]#
Return a string to be run using os.system in order to connect via the transport to the remote directory.
Expected behaviors:
A new bash session is opened
A reasonable error message is produced if the folder does not exist
- Parameters:
remotedir (str) – the full path of the remote directory
- listdir(path='.', pattern=None)[source]#
- Returns:
a list containing the names of the entries in the directory.
- Parameters:
path – default =’.’
pattern – if set, returns the list of files matching pattern. Unix only. (Use to emulate ls * for example)
- makedirs(path, ignore_existing=False)[source]#
Super-mkdir; create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not just the rightmost) will be created if it does not exist.
- Parameters:
path – directory to create
ignore_existing – if set to true, it doesn’t give any error if the leaf directory does already exist
- Raises:
OSError – If the directory already exists and is not ignore_existing
- mkdir(path, ignore_existing=False)[source]#
Create a folder (directory) named path.
- Parameters:
path – name of the folder to create
ignore_existing – if True, does not give any error if the directory already exists
- Raises:
OSError – If the directory already exists.
- normalize(path='.')[source]#
Normalizes path, eliminating double slashes, etc.. :param path: path to normalize
- open()[source]#
Opens a local transport channel
- Raises:
aiida.common.InvalidOperation – if the channel is already open
- put(localpath, remotepath, *args, **kwargs)[source]#
Copies a file or a folder from localpath to remotepath. Automatically redirects to putfile or puttree.
- Parameters:
localpath – absolute path to local file
remotepath – path to remote file
dereference – if True follows symbolic links. Default = True
overwrite – if True overwrites remotepath. Default = False
- Raises:
OSError – if remotepath is not valid
ValueError – if localpath is not valid
- putfile(localpath, remotepath, *args, **kwargs)[source]#
Copies a file from localpath to remotepath. Automatically redirects to putfile or puttree.
- Parameters:
localpath – absolute path to local file
remotepath – path to remote file
overwrite – if True overwrites remotepath Default = False
- Raises:
OSError – if remotepath is not valid
ValueError – if localpath is not valid
OSError – if localpath does not exist
- puttree(localpath, remotepath, *args, **kwargs)[source]#
Copies a folder recursively from localpath to remotepath. Automatically redirects to putfile or puttree.
- Parameters:
localpath – absolute path to local file
remotepath – path to remote file
dereference – follow symbolic links. Default = True
overwrite – if True overwrites remotepath. Default = False
- Raises:
OSError – if remotepath is not valid
ValueError – if localpath is not valid
OSError – if localpath does not exist
- rename(oldpath, newpath)[source]#
Rename a file or folder from oldpath to newpath.
- Parameters:
- Raises:
OSError – if src/dst is not found
ValueError – if src/dst is not a valid string
Plugin for transport over SSH (and SFTP for file transfer).
- class aiida.transports.plugins.ssh.SshTransport(*args, **kwargs)[source]#
Bases:
Transport
Support connection, command execution and data transfer to remote computers via SSH+SFTP.
- _MAX_EXEC_COMMAND_LOG_SIZE = None#
- __abstractmethods__ = frozenset({})#
- __init__(*args, **kwargs)[source]#
Initialize the SshTransport class.
- Parameters:
machine – the machine to connect to
load_system_host_keys – (optional, default False) if False, do not load the system host keys
key_policy – (optional, default = paramiko.RejectPolicy()) the policy to use for unknown keys
Other parameters valid for the ssh connect function (see the self._valid_connect_params list) are passed to the connect function (as port, username, password, …); taken from the accepted paramiko.SSHClient.connect() params.
- __module__ = 'aiida.transports.plugins.ssh'#
- _abc_impl = <_abc._abc_data object>#
- _exec_command_internal(command, combine_stderr=False, bufsize=-1)[source]#
Executes the specified command in bash login shell.
Before the command is executed, changes directory to the current working directory as returned by self.getcwd().
For executing commands and waiting for them to finish, use exec_command_wait.
- Parameters:
command – the command to execute. The command is assumed to be already escaped using
aiida.common.escaping.escape_for_bash()
.combine_stderr – (default False) if True, combine stdout and stderr on the same buffer (i.e., stdout). Note: If combine_stderr is True, stderr will always be empty.
bufsize – same meaning of the one used by paramiko.
- Returns:
a tuple with (stdin, stdout, stderr, channel), where stdin, stdout and stderr behave as file-like objects, plus the methods provided by paramiko, and channel is a paramiko.Channel object.
- classmethod _get_allow_agent_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_compress_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_gss_auth_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_gss_deleg_creds_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_gss_host_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_gss_kex_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_key_filename_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_key_policy_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_load_system_host_keys_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_look_for_keys_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_port_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_proxy_command_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- classmethod _get_proxy_jump_suggestion_string(_)[source]#
Return an empty suggestion since Paramiko does not parse ProxyJump from the SSH config.
- classmethod _get_timeout_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
Provide 60s as a default timeout for connections.
- classmethod _get_username_suggestion_string(computer)[source]#
Return a suggestion for the specific field.
- static _local_listdir(path, pattern=None)[source]#
Acts on the local folder, for the rest, same as listdir
- static _os_path_split_asunder(path)[source]#
Used by makedirs. Takes path (a str) and returns a list deconcatenating the path
- _symlink(source, dest)[source]#
Wrap SFTP symlink call without breaking API
- Parameters:
source – source of link
dest – link to create
- _valid_auth_options: list = [('username', {'help': 'Login user name on the remote machine.', 'non_interactive_default': True, 'prompt': 'User name'}), ('port', {'non_interactive_default': True, 'option': <aiida.cmdline.params.options.overridable.OverridableOption object>, 'prompt': 'Port number'}), ('look_for_keys', {'default': True, 'help': 'Automatically look for private keys in the ~/.ssh folder.', 'non_interactive_default': True, 'prompt': 'Look for keys', 'switch': True}), ('key_filename', {'help': 'Absolute path to your private SSH key. Leave empty to use the path set in the SSH config.', 'non_interactive_default': True, 'prompt': 'SSH key file', 'type': ABSOLUTEPATHEMPTY}), ('timeout', {'help': 'Time in seconds to wait for connection before giving up. Leave empty to use default value.', 'non_interactive_default': True, 'prompt': 'Connection timeout in s', 'type': <class 'int'>}), ('allow_agent', {'default': False, 'help': 'Switch to allow or disallow using an SSH agent.', 'non_interactive_default': True, 'prompt': 'Allow ssh agent', 'switch': True}), ('proxy_jump', {'help': 'SSH proxy jump for tunneling through other SSH hosts. Use a comma-separated list of hosts of the form [user@]host[:port]. If user or port are not specified for a host, the user & port values from the target host are used. This option must be provided explicitly and is not parsed from the SSH config file when left empty.', 'non_interactive_default': True, 'prompt': 'SSH proxy jump'}), ('proxy_command', {'help': 'SSH proxy command for tunneling through a proxy server. For tunneling through another SSH host, consider using the "SSH proxy jump" option instead! Leave empty to parse the proxy command from the SSH config file.', 'non_interactive_default': True, 'prompt': 'SSH proxy command'}), ('compress', {'default': True, 'help': 'Turn file transfer compression on or off.', 'non_interactive_default': True, 'prompt': 'Compress file transfers', 'switch': True}), ('gss_auth', {'default': False, 'help': 'Enable when using GSS kerberos token to connect.', 'non_interactive_default': True, 'prompt': 'GSS auth', 'type': <class 'bool'>}), ('gss_kex', {'default': False, 'help': 'GSS kex for kerberos, if not configured in SSH config file.', 'non_interactive_default': True, 'prompt': 'GSS kex', 'type': <class 'bool'>}), ('gss_deleg_creds', {'default': False, 'help': 'GSS deleg_creds for kerberos, if not configured in SSH config file.', 'non_interactive_default': True, 'prompt': 'GSS deleg_creds', 'type': <class 'bool'>}), ('gss_host', {'help': 'GSS host for kerberos, if not configured in SSH config file.', 'non_interactive_default': True, 'prompt': 'GSS host'}), ('load_system_host_keys', {'default': True, 'help': 'Load system host keys from default SSH location.', 'non_interactive_default': True, 'prompt': 'Load system host keys', 'switch': True}), ('key_policy', {'default': 'RejectPolicy', 'help': 'SSH key policy if host is not known.', 'non_interactive_default': True, 'prompt': 'Key policy', 'type': Choice(['RejectPolicy', 'WarningPolicy', 'AutoAddPolicy'])})]#
- _valid_connect_options = [('username', {'help': 'Login user name on the remote machine.', 'non_interactive_default': True, 'prompt': 'User name'}), ('port', {'non_interactive_default': True, 'option': <aiida.cmdline.params.options.overridable.OverridableOption object>, 'prompt': 'Port number'}), ('look_for_keys', {'default': True, 'help': 'Automatically look for private keys in the ~/.ssh folder.', 'non_interactive_default': True, 'prompt': 'Look for keys', 'switch': True}), ('key_filename', {'help': 'Absolute path to your private SSH key. Leave empty to use the path set in the SSH config.', 'non_interactive_default': True, 'prompt': 'SSH key file', 'type': ABSOLUTEPATHEMPTY}), ('timeout', {'help': 'Time in seconds to wait for connection before giving up. Leave empty to use default value.', 'non_interactive_default': True, 'prompt': 'Connection timeout in s', 'type': <class 'int'>}), ('allow_agent', {'default': False, 'help': 'Switch to allow or disallow using an SSH agent.', 'non_interactive_default': True, 'prompt': 'Allow ssh agent', 'switch': True}), ('proxy_jump', {'help': 'SSH proxy jump for tunneling through other SSH hosts. Use a comma-separated list of hosts of the form [user@]host[:port]. If user or port are not specified for a host, the user & port values from the target host are used. This option must be provided explicitly and is not parsed from the SSH config file when left empty.', 'non_interactive_default': True, 'prompt': 'SSH proxy jump'}), ('proxy_command', {'help': 'SSH proxy command for tunneling through a proxy server. For tunneling through another SSH host, consider using the "SSH proxy jump" option instead! Leave empty to parse the proxy command from the SSH config file.', 'non_interactive_default': True, 'prompt': 'SSH proxy command'}), ('compress', {'default': True, 'help': 'Turn file transfer compression on or off.', 'non_interactive_default': True, 'prompt': 'Compress file transfers', 'switch': True}), ('gss_auth', {'default': False, 'help': 'Enable when using GSS kerberos token to connect.', 'non_interactive_default': True, 'prompt': 'GSS auth', 'type': <class 'bool'>}), ('gss_kex', {'default': False, 'help': 'GSS kex for kerberos, if not configured in SSH config file.', 'non_interactive_default': True, 'prompt': 'GSS kex', 'type': <class 'bool'>}), ('gss_deleg_creds', {'default': False, 'help': 'GSS deleg_creds for kerberos, if not configured in SSH config file.', 'non_interactive_default': True, 'prompt': 'GSS deleg_creds', 'type': <class 'bool'>}), ('gss_host', {'help': 'GSS host for kerberos, if not configured in SSH config file.', 'non_interactive_default': True, 'prompt': 'GSS host'})]#
- _valid_connect_params = ['username', 'port', 'look_for_keys', 'key_filename', 'timeout', 'allow_agent', 'proxy_jump', 'proxy_command', 'compress', 'gss_auth', 'gss_kex', 'gss_deleg_creds', 'gss_host']#
- chdir(path)[source]#
Change directory of the SFTP session. Emulated internally by paramiko.
Differently from paramiko, if you pass None to chdir, nothing happens and the cwd is unchanged.
- chmod(path, mode)[source]#
Change permissions to path
- Parameters:
path – path to file
mode – new permission bits (integer)
- chown(path, uid, gid)[source]#
Change owner permissions of a file.
For now, this is not implemented for the SSH transport.
- close()[source]#
Close the SFTP channel, and the SSHClient.
- Todo:
correctly manage exceptions
- Raises:
aiida.common.InvalidOperation – if the channel is already open
- copy(remotesource, remotedestination, dereference=False, recursive=True)[source]#
Copy a file or a directory from remote source to remote destination. Flags used:
-r
: recursive copy;-f
: force, makes the command non interactive;-L
follows symbolic links- Parameters:
remotesource – file to copy from
remotedestination – file to copy to
dereference – if True, copy content instead of copying the symlinks only Default = False.
recursive (bool) – if True copy directories recursively. Note that if the remotesource is a directory, recursive should always be set to True. Default = True.
- Raises:
OSError – if the cp execution failed.
Note
setting dereference equal to True could cause infinite loops.
- copyfile(remotesource, remotedestination, dereference=False)[source]#
Copy a file from remote source to remote destination (On the same remote machine)
- Parameters:
- Raises:
OSError – if one of src or dst does not exist
- copytree(remotesource, remotedestination, dereference=False)[source]#
Copy a folder from remote source to remote destination (On the same remote machine)
- Parameters:
- Raises:
OSError – if one of src or dst does not exist
- exec_command_wait_bytes(command, stdin=None, combine_stderr=False, bufsize=-1, timeout=0.01)[source]#
Executes the specified command and waits for it to finish.
- Parameters:
command – the command to execute
stdin – (optional,default=None) can be a string or a file-like object.
combine_stderr – (optional, default=False) see docstring of self._exec_command_internal()
bufsize – same meaning of paramiko.
timeout – ssh channel timeout for stdout, stderr.
- Returns:
a tuple with (return_value, stdout, stderr) where stdout and stderr are both bytes and the return_value is an int.
- get(remotepath, localpath, callback=None, dereference=True, overwrite=True, ignore_nonexisting=False)[source]#
Get a file or folder from remote to local. Redirects to getfile or gettree.
- Parameters:
remotepath – a remote path
localpath – an (absolute) local path
dereference – follow symbolic links. Default = True (default behaviour in paramiko). False is not implemented.
overwrite – if True overwrites files and folders. Default = False
- Raises:
ValueError – if local path is invalid
OSError – if the remotepath is not found
- get_attribute(path)[source]#
Returns the object Fileattribute, specified in aiida.transports Receives in input the path of a given file.
- getcwd()[source]#
Return the current working directory for this SFTP session, as emulated by paramiko. If no directory has been set with chdir, this method will return None. But in __enter__ this is set explicitly, so this should never happen within this class.
- getfile(remotepath, localpath, callback=None, dereference=True, overwrite=True)[source]#
Get a file from remote to local.
- Parameters:
remotepath – a remote path
localpath – an (absolute) local path
overwrite – if True overwrites files and folders. Default = False
- Raises:
ValueError – if local path is invalid
OSError – if unintentionally overwriting
- gettree(remotepath, localpath, callback=None, dereference=True, overwrite=True)[source]#
Get a folder recursively from remote to local.
- Parameters:
remotepath – a remote path
localpath – an (absolute) local path
dereference – follow symbolic links. Default = True (default behaviour in paramiko). False is not implemented.
overwrite – if True overwrites files and folders. Default = False
- Raises:
ValueError – if local path is invalid
OSError – if the remotepath is not found
OSError – if unintentionally overwriting
- gotocomputer_command(remotedir)[source]#
Specific gotocomputer string to connect to a given remote computer via ssh and directly go to the calculation folder.
- isdir(path)[source]#
Return True if the given path is a directory, False otherwise. Return False also if the path does not exist.
- isfile(path)[source]#
Return True if the given path is a file, False otherwise. Return False also if the path does not exist.
- listdir(path='.', pattern=None)[source]#
Get the list of files at path.
- Parameters:
path – default = ‘.’
pattern – returns the list of files matching pattern. Unix only. (Use to emulate
ls *
for example)
- lstat(path)[source]#
Retrieve information about a file on the remote system, without following symbolic links (shortcuts). This otherwise behaves exactly the same as stat.
- Parameters:
path (str) – the filename to stat
- Returns:
a paramiko.sftp_attr.SFTPAttributes object containing attributes about the given file.
- makedirs(path, ignore_existing=False)[source]#
Super-mkdir; create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not just the rightmost) will be created if it does not exist.
NOTE: since os.path.split uses the separators as the host system (that could be windows), I assume the remote computer is Linux-based and use ‘/’ as separators!
- Parameters:
path – directory to create (string)
ignore_existing – if set to true, it doesn’t give any error if the leaf directory does already exist (bool)
- Raises:
OSError – If the directory already exists.
- mkdir(path, ignore_existing=False)[source]#
Create a folder (directory) named path.
- Parameters:
path – name of the folder to create
ignore_existing – if True, does not give any error if the directory already exists
- Raises:
OSError – If the directory already exists.
- open()[source]#
Open a SSHClient to the machine possibly using the parameters given in the __init__.
Also opens a sftp channel, ready to be used. The current working directory is set explicitly, so it is not None.
- Raises:
aiida.common.InvalidOperation – if the channel is already open
- put(localpath, remotepath, callback=None, dereference=True, overwrite=True, ignore_nonexisting=False)[source]#
Put a file or a folder from local to remote. Redirects to putfile or puttree.
- Parameters:
localpath – an (absolute) local path
remotepath – a remote path
dereference – follow symbolic links (boolean). Default = True (default behaviour in paramiko). False is not implemented.
overwrite – if True overwrites files and folders (boolean). Default = False.
- Raises:
ValueError – if local path is invalid
OSError – if the localpath does not exist
- putfile(localpath, remotepath, callback=None, dereference=True, overwrite=True)[source]#
Put a file from local to remote.
- Parameters:
localpath – an (absolute) local path
remotepath – a remote path
overwrite – if True overwrites files and folders (boolean). Default = True.
- Raises:
ValueError – if local path is invalid
OSError – if the localpath does not exist, or unintentionally overwriting
- puttree(localpath, remotepath, callback=None, dereference=True, overwrite=True)[source]#
Put a folder recursively from local to remote.
By default, overwrite.
- Parameters:
localpath – an (absolute) local path
remotepath – a remote path
dereference – follow symbolic links (boolean) Default = True (default behaviour in paramiko). False is not implemented.
overwrite – if True overwrites files and folders (boolean). Default = True
- Raises:
ValueError – if local path is invalid
OSError – if the localpath does not exist, or trying to overwrite
OSError – if remotepath is invalid
Note
setting dereference equal to True could cause infinite loops. see os.walk() documentation
- rename(oldpath, newpath)[source]#
Rename a file or folder from oldpath to newpath.
- Parameters:
- Raises:
OSError – if oldpath/newpath is not found
ValueError – if sroldpathc/newpath is not a valid string
- rmtree(path)[source]#
Remove a file or a directory at path, recursively Flags used: -r: recursive copy; -f: force, makes the command non interactive;
- Parameters:
path – remote path to delete
- Raises:
OSError – if the rm execution failed.
- property sftp#
- property sshclient#
- stat(path)[source]#
Retrieve information about a file on the remote system. The return value is an object whose attributes correspond to the attributes of Python’s
stat
structure as returned byos.stat
, except that it contains fewer fields. The fields supported are:st_mode
,st_size
,st_uid
,st_gid
,st_atime
, andst_mtime
.- Parameters:
path (str) – the filename to stat
- Returns:
a paramiko.sftp_attr.SFTPAttributes object containing attributes about the given file.
- aiida.transports.plugins.ssh.convert_to_bool(string)[source]#
Convert a string passed in the CLI to a valid bool.
- Returns:
the parsed bool value.
- Raises:
ValueError – If the value is not parsable as a bool
- aiida.transports.plugins.ssh.parse_sshconfig(computername)[source]#
Return the ssh configuration for a given computer name.
This parses the
.ssh/config
file in the home directory and returns the part of configuration of the given computer name.- Parameters:
computername – the computer name for which we want the configuration.
Plugin for transport over SSH (and SFTP for file transfer).
- class aiida.transports.plugins.ssh_auto.SshAutoTransport(*args, **kwargs)[source]#
Bases:
SshTransport
Support connection, command execution and data transfer to remote computers via SSH+SFTP.
- __abstractmethods__ = frozenset({})#
- __annotations__ = {'FILEPATH_CONFIG': <class 'pathlib.Path'>, '_valid_auth_options': 'list'}#
- __init__(*args, **kwargs)[source]#
Initialize the SshTransport class.
- Parameters:
machine – the machine to connect to
load_system_host_keys – (optional, default False) if False, do not load the system host keys
key_policy – (optional, default = paramiko.RejectPolicy()) the policy to use for unknown keys
Other parameters valid for the ssh connect function (see the self._valid_connect_params list) are passed to the connect function (as port, username, password, …); taken from the accepted paramiko.SSHClient.connect() params.
- __module__ = 'aiida.transports.plugins.ssh_auto'#
- _abc_impl = <_abc._abc_data object>#
- _valid_connect_params = []#