I'm trying to connect through Paramiko to an external SFTP and passing an encrypted config file for the credentials. When attempting to connect with the following, I get an error for the exception client.close that states AttributeError: 'Nonetype' object has not attribute 'close':
client = None
try:
client = paramiko.Transport(hostname, port)
client.connect(username=username, password=password)
except Exception as e:
client.close()
return 'Cannot connect to SFTP server: ' + str(e.args[-1]), []
# Go
sftp = paramiko.SFTPClient.from_transport(client)