Skip to content

Commit

Permalink
Merge pull request liberation#18 from nahuelange/support-sftp-protoco…
Browse files Browse the repository at this point in the history
…l-16

[liberation#16] change the way to create sftp connection
  • Loading branch information
nahuelange committed May 17, 2016
2 parents 6618f94 + a397edc commit 879495d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions carrier_pigeon/senders.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,18 @@ def _connect(self, file_path, target_url):
class SFTPSender(DefaultSender):

def _connect(self, file_path, target_url):
transport = paramiko.Transport(
(target_url.domain,
target_url.port if target_url.port else 22)
)
self.client = paramiko.SSHClient()

transport.connect(username=target_url.login,
password=target_url.password)
self.client.set_missing_host_key_policy(paramiko.MissingHostKeyPolicy())

sftp = paramiko.SFTPClient.from_transport(transport)
self.client.connect(
target_url.domain,
port=target_url.port if target_url.port else 22,
username=target_url.login,
password=target_url.password
)

return sftp
return self.client.open_sftp()

def _send_file(self, file_path, target_url, row=None):
sftp = self._connect(file_path, target_url)
Expand Down

0 comments on commit 879495d

Please sign in to comment.