def sftp_connect(conf):
 sftp = None
 tries = CONNECT_TRIES
 retry_interval = RETRY_INTERVAL
 while (not sftp):
  try:
   sftp = pysftp.Connection(host=conf.host, username=conf.username, private_key=conf.private_key, password=conf.password, port=conf.port, private_key_pass=conf.private_key_pass)
   sftp.timeout = SOCKET_TIMEOUT
   log.verbose((u'Connected to %s' % conf.host))
  except Exception as e:
   if (not tries):
    raise e
   else:
    log.debug((u'Caught exception: %s' % e))
    log.warning((u'Failed to connect to %s; waiting %d seconds before retrying.' % (conf.host, retry_interval)))
    time.sleep(retry_interval)
    tries -= 1
    retry_interval += RETRY_STEP
 return sftp

def sftp_connect ( conf ) : sftp = None tries = CONNECT_TRIES retry_interval = RETRY_INTERVAL while ( not sftp ) : try : sftp = pysftp . Connection ( host = conf . host , username = conf . username , private_key = conf . private_key , password = conf . password , port = conf . port , private_key_pass = conf . private_key_pass ) sftp . timeout = SOCKET_TIMEOUT log . verbose ( ( u'Connected to %s' % conf . host ) ) except Exception as e : if ( not tries ) : raise e else : log . debug ( ( u'Caught exception: %s' % e ) ) log . warning ( ( u'Failed to connect to %s; waiting %d seconds before retrying.' % ( conf . host , retry_interval ) ) ) time . sleep ( retry_interval ) tries -= 1 retry_interval += RETRY_STEP return sftp
helper function to connect to an sftp server .