Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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!"))
import pysftp
import paramiko
from globus import GLOBUSError
from spot import SPOTError
from newt import NEWTError
import ssh
__all__ = ['newt', 'spot', 'globus', 'sftp', 'ssh']
# Exceptions raised by clients that we care to handle
EXCEPTIONS = (pysftp.ConnectionException, paramiko.ssh_exception.BadAuthenticationType,
paramiko.ssh_exception.AuthenticationException, GLOBUSError, SPOTError, GLOBUSError)