Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions pooch/downloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,18 @@ def __call__(self, url, output_file, pooch):
The instance of :class:`~pooch.Pooch` that is calling this method.
"""
parsed_url = parse_url(url)
connection = paramiko.Transport(sock=(parsed_url["netloc"], self.port))
client = paramiko.SSHClient()
sftp = None
try:
connection.connect(username=self.username, password=self.password)
sftp = paramiko.SFTPClient.from_transport(connection)
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(
hostname=parsed_url["netloc"],
port=self.port,
username=self.username,
password=self.password,
)
sftp = client.open_sftp()
sftp.get_channel().settimeout = self.timeout
if self.progressbar:
size = int(sftp.stat(parsed_url["path"]).st_size)
Expand All @@ -484,7 +491,7 @@ def callback(current, total):
else:
sftp.get(parsed_url["path"], output_file)
finally:
connection.close()
client.close()
if sftp is not None:
sftp.close()

Expand Down