network.ftp

network.ftp

Functions

Name Description
ftp_download Downloads file_local on ftp, from server directory dir_server
ftp_list Returns the list of fles matching pattern on dir_server
ftp_upload FTP upload function
get_auth_ftp get netrc credentials for use with pyfilesystem’s
get_url_ftpfs get netrc credentials for use with pyfilesystem’s fs.open_fs

ftp_download

network.ftp.ftp_download(ftp, file_local, dir_server, verbose=True)

Downloads file_local on ftp, from server directory dir_server

The file name on the server is determined by file_local.name

Example: ftp = FTP(**get_auth_ftp(‘my_server’)) local_file = Path(‘./data.txt’) ftp_download(ftp, local_file, ‘/remote/folder’) ftp.quit()

Refs: https://stackoverflow.com/questions/19692739/ https://stackoverflow.com/questions/73534659/

ftp_list

network.ftp.ftp_list(ftp, dir_server, pattern='*')

Returns the list of fles matching pattern on dir_server

ftp_upload

network.ftp.ftp_upload(
    ftp,
    file_local,
    dir_server,
    if_exists='skip',
    blocksize=8192,
    verbose=True,
)

FTP upload function

  • Use temporary files
  • Create remote directories
  • if_exists: ‘skip’: skip the existing file ‘error’: raise an error on existing file ‘overwrite’: overwrite existing file

get_auth_ftp

network.ftp.get_auth_ftp(name)

get netrc credentials for use with pyfilesystem’s FTPFS or ftplib’s FTP

Ex: FTP(**get_auth_ftp())

get_url_ftpfs

network.ftp.get_url_ftpfs(name)

get netrc credentials for use with pyfilesystem’s fs.open_fs

Ex: fs.open_fs(get_url_ftpfs())