Base class for the SFTP implementation. More...
Public Member Functions | |
| def | __init__ (self, encoding) |
| def | is_file (self, path) |
Checks if the path points to a regular file on the remote host. More... | |
| def | is_dir (self, path) |
Checks if the path points to a directory on the remote host. More... | |
| def | list_dir (self, path, pattern=None, absolute=False) |
Gets the item names, or optionally the absolute paths, on the given path on the remote host. More... | |
| def | list_files_in_dir (self, path, pattern=None, absolute=False) |
Gets the file names, or optionally the absolute paths, of the regular files on the given path on the remote host. More... | |
| def | list_dirs_in_dir (self, path, pattern=None, absolute=False) |
Gets the directory names, or optionally the absolute paths, on the given path on the remote host. More... | |
| def | get_directory (self, source, destination, scp_preserve_time, path_separator='/', recursive=False) |
| def | build_destination (self, source, destination, path_separator) |
| Add parent directory from source to destination path if destination is '. More... | |
| def | get_parent_folder (self, source, path_separator) |
| def | get_file (self, source, destination, scp_preserve_times, path_separator='/') |
| Downloads file(s) from the remote host to the local machine. More... | |
| def | put_directory (self, source, destination, scp_preserve_times, mode, newline, path_separator='/', recursive=False) |
| Uploads directory(-ies) from the local machine to the remote host, optionally with subdirectories included. More... | |
| def | put_file (self, sources, destination, scp_preserve_times, mode, newline, path_separator='/') |
| Uploads the file(s) from the local machine to the remote host. More... | |
| def | create_local_ssh_tunnel (self, local_port, remote_host, remote_port, client) |
Private Member Functions | |
| def | _absolute_path (self, path) |
| def | _stat (self, path) |
| def | _list_filtered (self, path, filter_method, pattern=None, absolute=False) |
| def | _verify_remote_dir_exists (self, path) |
| def | _get_item_names (self, path) |
| def | _list (self, path) |
| def | _filter_by_pattern (self, items, pattern) |
| def | _include_absolute_path (self, items, path) |
| def | _get_file_names (self, path) |
| def | _is_dir_symlink (self, path, item) |
| def | _get_directory_names (self, path) |
| def | _get_directory (self, source, destination, path_separator='/', recursive=False, scp_preserve_times=False) |
| Downloads directory(-ies) from the remote host to the local machine, optionally with subdirectories included. More... | |
| def | _remove_ending_path_separator (self, path_separator, source) |
| def | _get_get_file_sources (self, source, path_separator) |
| def | _get_get_file_destinations (self, source_files, destination) |
| def | _create_missing_local_dirs (self, destination, target_is_dir) |
| def | _get_file (self, source, destination, scp_preserve_times) |
| def | _put_directory (self, source, destination, mode, newline, path_separator, recursive, scp_preserve_times=False) |
| def | _verify_local_dir_exists (self, path) |
| def | _get_put_file_sources (self, source) |
| def | _get_put_file_destinations (self, sources, destination, path_separator) |
| def | _format_destination_path (self, destination) |
| def | _parse_path_elements (self, destination, path_separator) |
| def | _create_missing_remote_path (self, path, mode) |
| def | _put_file (self, source, destination, mode, newline, path_separator, scp_preserve_times=False) |
| def | _create_remote_file (self, destination, mode) |
| def | _write_to_remote_file (self, remote_file, data, position) |
| def | _close_remote_file (self, remote_file) |
| def | _readlink (self, path) |
Private Attributes | |
| _encoding | |
| _homedir | |
Base class for the SFTP implementation.
Classes derived from this class (i.e. :py:class:`pythonclient.SFTPClient` and :py:class:`javaclient.SFTPClient`) provide the concrete and the language specific implementations for getting, putting and listing files and directories.
Definition at line 813 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.__init__ | ( | self, | |
| encoding | |||
| ) |
Definition at line 815 of file abstractclient.py.
|
private |
Reimplemented in SSHLibrary.pythonclient.SFTPClient, and SSHLibrary.javaclient.SFTPClient.
Definition at line 819 of file abstractclient.py.
|
private |
Reimplemented in SSHLibrary.pythonclient.SFTPClient, and SSHLibrary.javaclient.SFTPClient.
Definition at line 1304 of file abstractclient.py.
|
private |
Definition at line 1103 of file abstractclient.py.
|
private |
Reimplemented in SSHLibrary.pythonclient.SFTPClient.
Definition at line 1269 of file abstractclient.py.
|
private |
Reimplemented in SSHLibrary.pythonclient.SFTPClient, and SSHLibrary.javaclient.SFTPClient.
Definition at line 1298 of file abstractclient.py.
|
private |
Definition at line 901 of file abstractclient.py.
|
private |
Definition at line 1251 of file abstractclient.py.
|
private |
Downloads directory(-ies) from the remote host to the local machine, optionally with subdirectories included.
:param str source: The path to the directory on the remote machine.
:param str destination: The target path on the local machine. The destination defaults to the current local working directory.
:param bool scp_preserve_times: preserve modification time and access time of transferred files and directories.
:param str path_separator: The path separator used for joining the paths on the remote host. On Windows, this must be set as \. The default is /, which is also the default on Linux-like systems.
:param bool recursive: If True, the subdirectories in the source path are downloaded as well.
:returns: A list of 2-tuples for all the downloaded files. These tuples contain the remote path as the first value and the local target path as the second.
Definition at line 997 of file abstractclient.py.
|
private |
Definition at line 965 of file abstractclient.py.
|
private |
Reimplemented in SSHLibrary.pythonclient.SCPTransferClient, SSHLibrary.pythonclient.SFTPClient, SSHLibrary.javaclient.SCPTransferClient, and SSHLibrary.javaclient.SFTPClient.
Definition at line 1109 of file abstractclient.py.
|
private |
Definition at line 933 of file abstractclient.py.
|
private |
Definition at line 1091 of file abstractclient.py.
|
private |
Definition at line 1078 of file abstractclient.py.
|
private |
Definition at line 895 of file abstractclient.py.
|
private |
Definition at line 1233 of file abstractclient.py.
|
private |
Definition at line 1222 of file abstractclient.py.
|
private |
Definition at line 904 of file abstractclient.py.
|
private |
Definition at line 940 of file abstractclient.py.
|
private |
Reimplemented in SSHLibrary.pythonclient.SFTPClient, and SSHLibrary.javaclient.SFTPClient.
Definition at line 898 of file abstractclient.py.
|
private |
Definition at line 881 of file abstractclient.py.
|
private |
Definition at line 1256 of file abstractclient.py.
|
private |
Definition at line 1152 of file abstractclient.py.
|
private |
Reimplemented in SSHLibrary.pythonclient.SCPTransferClient, and SSHLibrary.javaclient.SCPTransferClient.
Definition at line 1284 of file abstractclient.py.
|
private |
Reimplemented in SSHLibrary.pythonclient.SFTPClient, and SSHLibrary.javaclient.SFTPClient.
Definition at line 1310 of file abstractclient.py.
|
private |
Definition at line 1039 of file abstractclient.py.
|
private |
Reimplemented in SSHLibrary.pythonclient.SFTPClient, and SSHLibrary.javaclient.SFTPClient.
Definition at line 838 of file abstractclient.py.
|
private |
Definition at line 1172 of file abstractclient.py.
|
private |
Definition at line 890 of file abstractclient.py.
|
private |
Reimplemented in SSHLibrary.pythonclient.SFTPClient, and SSHLibrary.javaclient.SFTPClient.
Definition at line 1301 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.build_destination | ( | self, | |
| source, | |||
| destination, | |||
| path_separator | |||
| ) |
Add parent directory from source to destination path if destination is '.
' or if destination already exists. Otherwise the missing intermediate directories are created.
:return: A new destination path.
Definition at line 1024 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.create_local_ssh_tunnel | ( | self, | |
| local_port, | |||
| remote_host, | |||
| remote_port, | |||
| client | |||
| ) |
Definition at line 1307 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.get_directory | ( | self, | |
| source, | |||
| destination, | |||
| scp_preserve_time, | |||
path_separator = '/', |
|||
recursive = False |
|||
| ) |
Definition at line 968 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.get_file | ( | self, | |
| source, | |||
| destination, | |||
| scp_preserve_times, | |||
path_separator = '/' |
|||
| ) |
Downloads file(s) from the remote host to the local machine.
:param str source: Must be the path to an existing file on the remote
machine or a glob pattern.
Glob patterns, like '*' and '?', can be used in the source, in
which case all the matching files are downloaded.
:param str destination: The target path on the local machine.
If many files are downloaded, e.g. patterns are used in the
`source`, then this must be a path to an existing directory.
The destination defaults to the current local working directory.
:param bool scp_preserve_times: preserve modification time and access time
of transferred files and directories.
:param str path_separator: The path separator used for joining the
paths on the remote host. On Windows, this must be set as `\`.
The default is `/`, which is also the default on Linux-like systems.
:returns: A list of 2-tuples for all the downloaded files. These tuples
contain the remote path as the first value and the local target
path as the second.
Definition at line 1067 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.get_parent_folder | ( | self, | |
| source, | |||
| path_separator | |||
| ) |
Definition at line 1033 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.is_dir | ( | self, | |
| path | |||
| ) |
Checks if the path points to a directory on the remote host.
If the `path` is a symlink, its destination is checked instead.
:param str path: The path to check.
:returns: `True`, if the `path` is points to an existing directory.
False otherwise.
Definition at line 850 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.is_file | ( | self, | |
| path | |||
| ) |
Checks if the path points to a regular file on the remote host.
If the `path` is a symlink, its destination is checked instead.
:param str path: The path to check.
:returns: `True`, if the `path` is points to an existing regular file.
False otherwise.
Definition at line 831 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.list_dir | ( | self, | |
| path, | |||
pattern = None, |
|||
absolute = False |
|||
| ) |
Gets the item names, or optionally the absolute paths, on the given path on the remote host.
This includes regular files, directories as well as other file types, e.g. device files.
:param str path: The path on the remote host to list.
:param str pattern: If given, only the item names that match the given pattern are returned. Please do note, that the pattern is never matched against the full path, even if absolute is set True.
:param bool absolute: If True, the absolute paths of the items are returned instead of the item names.
:returns: A list containing either the item names or the absolute paths. In both cases, the List is first filtered by the pattern if it is given.
Definition at line 877 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.list_dirs_in_dir | ( | self, | |
| path, | |||
pattern = None, |
|||
absolute = False |
|||
| ) |
Gets the directory names, or optionally the absolute paths, on the given path on the remote host.
:param str path: The path on the remote host to list.
:param str pattern: If given, only the directory names that match the given pattern are returned. Please do note, that the pattern is never matched against the full path, even if absolute is set True.
:param bool absolute: If True, the absolute paths of the directories are returned instead of the directory names.
:returns: A list containing either the directory names or the absolute paths. In both cases, the List is first filtered by the pattern if it is given.
Definition at line 961 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.list_files_in_dir | ( | self, | |
| path, | |||
pattern = None, |
|||
absolute = False |
|||
| ) |
Gets the file names, or optionally the absolute paths, of the regular files on the given path on the remote host.
:param str path: The path on the remote host to list.
:param str pattern: If given, only the file names that match the given pattern are returned. Please do note, that the pattern is never matched against the full path, even if absolute is set True.
:param bool absolute: If True, the absolute paths of the regular files are returned instead of the file names.
:returns: A list containing either the regular file names or the absolute paths. In both cases, the List is first filtered by the pattern if it is given.
Definition at line 929 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.put_directory | ( | self, | |
| source, | |||
| destination, | |||
| scp_preserve_times, | |||
| mode, | |||
| newline, | |||
path_separator = '/', |
|||
recursive = False |
|||
| ) |
Uploads directory(-ies) from the local machine to the remote host, optionally with subdirectories included.
:param str source: The path to the directory on the local machine.
:param str destination: The target path on the remote host. The destination defaults to the user's home at the remote host.
:param bool scp_preserve_times: preserve modification time and access time of transferred files and directories.
:param str mode: The uploaded files on the remote host are created with these modes. The modes are given as traditional Unix octal permissions, such as '0600'.
:param str newline: If given, the newline characters of the uploaded files on the remote host are converted to this.
:param str path_separator: The path separator used for joining the paths on the remote host. On Windows, this must be set as \. The default is /, which is also the default on Linux-like systems.
:param bool recursive: If True, the subdirectories in the source path are uploaded as well.
:returns: A list of 2-tuples for all the uploaded files. These tuples contain the local path as the first value and the remote target path as the second.
Definition at line 1141 of file abstractclient.py.
| def SSHLibrary.abstractclient.AbstractSFTPClient.put_file | ( | self, | |
| sources, | |||
| destination, | |||
| scp_preserve_times, | |||
| mode, | |||
| newline, | |||
path_separator = '/' |
|||
| ) |
Uploads the file(s) from the local machine to the remote host.
:param str sources: Must be the path to an existing file on the remote
machine or a glob pattern .
Glob patterns, like '*' and '?', can be used in the source, in
which case all the matching files are uploaded.
:param str destination: The target path on the remote host.
If multiple files are uploaded, e.g. patterns are used in the
`source`, then this must be a path to an existing directory.
The destination defaults to the user's home at the remote host.
:param bool scp_preserve_times: preserve modification time and access time
of transferred files and directories.
:param str mode: The uploaded files on the remote host are created with
these modes. The modes are given as traditional Unix octal
permissions, such as '0600'. If 'None' value is provided,
setting permissions will be skipped.
:param str newline: If given, the newline characters of the uploaded
files on the remote host are converted to this.
:param str path_separator: The path separator used for joining the
paths on the remote host. On Windows, this must be set as `\`.
The default is `/`, which is also the default on Linux-like systems.
:returns: A list of 2-tuples for all the uploaded files. These tuples
contain the local path as the first value and the remote target
path as the second.
Definition at line 1208 of file abstractclient.py.
|
private |
Definition at line 816 of file abstractclient.py.
|
private |
Definition at line 817 of file abstractclient.py.