SHARE
TWEET

Untitled

a guest Jul 19th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def open_ftp_connection(ftp_host, ftp_port, ftp_username, ftp_password):
  2.   ...
  3.   Opens ftp connection and returns connection object
  4.   ...
  5.   client = paramiko.SSHClient()
  6.   client.load_system_host_keys()
  7.   try:
  8.     transport = paramiko.Transport(ftp_host, ftp_port)
  9.   except Exception as e:
  10.     return 'conn_error'
  11.   try:
  12.     transport.connect(username=ftp_username, password.ftp_password)
  13.   except Exception as identifier:
  14.     return 'auth_error'
  15.   ftp_connection = paramiko.SFTPClient.from_transport(transport)
  16.   return ftp_connection
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top