How to use the pysftp.CredentialException function in pysftp

To help you get started, we’ve selected a few pysftp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AwesomeFoodCoops / odoo-production / extra_addons / auto_backup / models / db_backup.py View on Github external
def action_sftp_test_connection(self):
        """Check if the SFTP settings are correct."""
        try:
            # Just open and close the connection
            with self.sftp_connection():
                raise exceptions.Warning(_("Connection Test Succeeded!"))
        except (pysftp.CredentialException, pysftp.ConnectionException):
            _logger.info("Connection Test Failed!", exc_info=True)
            raise exceptions.Warning(_("Connection Test Failed!"))
github it-projects-llc / odoo-saas-tools / saas_server_backup_ftp / models / res_config.py View on Github external
params["private_key_pass"] = self.rsa_key_passphrase
            else:
                params["password"] = self.sftp_password

            # not empty sftp_public_key means that we should verify sftp server with it
            cnopts = pysftp.CnOpts()
            if self.sftp_public_key:
                key = paramiko.RSAKey(data=base64.b64decode(self.sftp_public_key))
                cnopts.hostkeys.add(self.sftp_server, 'ssh-rsa', key)
            else:
                cnopts.hostkeys = None

            with pysftp.Connection(**params, cnopts=cnopts):
                raise exceptions.Warning(_("Connection Test Succeeded!"))

        except (pysftp.CredentialException,
                pysftp.ConnectionException,
                pysftp.SSHException):
            _logger.info("Connection Test Failed!", exc_info=True)
            raise exceptions.Warning(_("Connection Test Failed!"))