util.sftp ========= .. py:module:: util.sftp .. autoapi-nested-parse:: Wrapper around Paramiko SFTP functionality and related exceptions. Module Contents --------------- .. py:exception:: SftpError Bases: :py:obj:`Exception` Custom exception for any SFTP-related failures. .. py:class:: SftpClient(overrides = None) Wrapper around Paramiko SFTP functionality. If instantiated without overrides, reads settings from BackupOptions(pk=1). Optionally, an overrides dict can supply: host, port, user, auth_method, password, private_key, key_passphrase, local_storage, remote_directory. .. py:attribute:: host :type: str .. py:attribute:: port :type: int .. py:attribute:: username :type: str .. py:attribute:: auth_method :type: str .. py:attribute:: password :type: str | None .. py:attribute:: private_key_text :type: str | None .. py:attribute:: passphrase :type: str | None .. py:attribute:: remote_directory :type: str .. py:method:: test_connection() Attempt an SFTP connection with the current settings. :raises SftpError: If no auth_method, authentication fails, or any SSH error. .. py:method:: upload_file(local_filepath, remote_path) Upload a single local file to the remote_path via SFTP. :param local_filepath: Path to the local file to upload. :param remote_path: Full remote path (including filename) at the server. :raises SftpError: If no auth_method, local file missing, or any SSH/SFTP error.