Guest User

Untitled

a guest
Feb 2nd, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. import os
  2. import pysftp
  3. import stat
  4.  
  5. with pysftp.Connection('example.com', username='username', password='password') as sftp:
  6. sftp.cwd("/remote/path")
  7. for f in sftp.listdir_attr():
  8. if not stat.S_ISDIR(f.st_mode):
  9. print("Checking %s..." % f.filename)
  10. if ((not os.path.isfile(f.filename)) or
  11. (f.st_mtime > os.path.getmtime(f.filename))):
  12. print("Downloading %s..." % f.filename)
  13. sftp.get(f.filename, f.filename)
Add Comment
Please, Sign In to add comment