Reputation: 7102
I am using pysftp
to connect to a remote sftp server.
The syntax seems simple:
with pysftp.Connection('hostname', username='me', password='secret') as sftp:
with sftp.cd('/allcode'):
sftp.put('/pycode/filename')
But how can I check to make sure the pysftp.Connection
was successful and the sftp.put
actually uploaded the file? I would like to send an email notification if they are not.
Is there a way to do that?
Thanks!
Upvotes: 0
Views: 1141
Reputation: 83537
But how can I check to make sure the pysftp.Connection was successful and the sftp.put actually uploaded the file?
Most likely pysftp
will throw an exception if there is a problem. You shouldn't check for success before hand. Just send the file and assume it works. Add code to handle exceptions if they occur.
As the saying goes: it is better to ask for forgiveness than to ask for permission.
Upvotes: 1