Guest User

Untitled

a guest
Aug 11th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. Creating a new results/logging file using paramiko and sftp
  2. def csv_import():
  3. we_are_live = True
  4. host = "111.111.111.111"
  5. port = 22
  6. password = "cleverpwd"
  7. username = "cleverun"
  8. t = paramiko.Transport((host,port))
  9. t.connect(username=username, password=password)
  10. if we_are_live and t.is_authenticated():
  11. sftp = paramiko.SFTPClient.from_transport(t)
  12. sftp.chdir('.'+settings.REMOTE_SFTP_DIRECTORY)
  13. files_to_pick_from = sftp.listdir()
  14. …file processing code happens here, get back a dictionary of the results...
  15. results_file_name = 'results'+client_file_name
  16. results_file = paramiko.SFTPClient.from_transport(t)
  17. results_file.file(results_file_name,mode='w',bufsize=-1)
  18. results_file.write(str(sftp_results_of_import))
  19. results_file.close()
  20. t.close()
Add Comment
Please, Sign In to add comment