def ftp_put_command(connection, local_path, remote_dir):
 try:
  ftp = ftplib.FTP(host=connection.host, user=connection.username, passwd=connection.password)
  ftp.cwd(remote_dir)
  name = os.path.split(local_path)[1]
  f = open(local_path, 'rb')
  ftp.storbinary(('STOR ' + name), f)
  f.close()
  ftp.close()
 except Exception:
  LOG.error(_('File transfer to PowerVM manager failed'))
  raise exception.PowerVMFTPTransferFailed(ftp_cmd='PUT', source_path=local_path, dest_path=remote_dir)

def ftp_put_command ( connection , local_path , remote_dir ) : try : ftp = ftplib . FTP ( host = connection . host , user = connection . username , passwd = connection . password ) ftp . cwd ( remote_dir ) name = os . path . split ( local_path ) [ 1 ] f = open ( local_path , 'rb' ) ftp . storbinary ( ( 'STOR ' + name ) , f ) f . close ( ) ftp . close ( ) except Exception : LOG . error ( _ ( 'File transfer to PowerVM manager failed' ) ) raise exception . PowerVMFTPTransferFailed ( ftp_cmd = 'PUT' , source_path = local_path , dest_path = remote_dir )
method to transfer a file via ftp .