def ftp_get_command(connection, remote_path, local_path):
 try:
  ftp = ftplib.FTP(host=connection.host, user=connection.username, passwd=connection.password)
  ftp.cwd(os.path.dirname(remote_path))
  name = os.path.basename(remote_path)
  LOG.debug((_('ftp GET %(remote_path)s to: %(local_path)s') % locals()))
  with open(local_path, 'w') as ftpfile:
   ftpcmd = ('RETR %s' % name)
   ftp.retrbinary(ftpcmd, ftpfile.write)
  ftp.close()
 except Exception:
  LOG.error(_('File transfer from PowerVM manager failed'))
  raise exception.PowerVMFTPTransferFailed(ftp_cmd='GET', source_path=remote_path, dest_path=local_path)

def ftp_get_command ( connection , remote_path , local_path ) : try : ftp = ftplib . FTP ( host = connection . host , user = connection . username , passwd = connection . password ) ftp . cwd ( os . path . dirname ( remote_path ) ) name = os . path . basename ( remote_path ) LOG . debug ( ( _ ( 'ftp GET %(remote_path)s to: %(local_path)s' ) % locals ( ) ) ) with open ( local_path , 'w' ) as ftpfile : ftpcmd = ( 'RETR %s' % name ) ftp . retrbinary ( ftpcmd , ftpfile . write ) ftp . close ( ) except Exception : LOG . error ( _ ( 'File transfer from PowerVM manager failed' ) ) raise exception . PowerVMFTPTransferFailed ( ftp_cmd = 'GET' , source_path = remote_path , dest_path = local_path )
retrieve a file via ftp .