Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Creating a new results/logging file using paramiko and sftp
- def csv_import():
- we_are_live = True
- host = "111.111.111.111"
- port = 22
- password = "cleverpwd"
- username = "cleverun"
- t = paramiko.Transport((host,port))
- t.connect(username=username, password=password)
- if we_are_live and t.is_authenticated():
- sftp = paramiko.SFTPClient.from_transport(t)
- sftp.chdir('.'+settings.REMOTE_SFTP_DIRECTORY)
- files_to_pick_from = sftp.listdir()
- …file processing code happens here, get back a dictionary of the results...
- results_file_name = 'results'+client_file_name
- results_file = paramiko.SFTPClient.from_transport(t)
- results_file.file(results_file_name,mode='w',bufsize=-1)
- results_file.write(str(sftp_results_of_import))
- results_file.close()
- t.close()
Add Comment
Please, Sign In to add comment