iwfm.util.ftp_fetch

iwfm.util.ftp_fetch(server, dir, filename='download.txt', verbose=False)[source]

Download a file from a server and save to the specified directory and file name.

This function uses anonymous FTP login to access the server. Anonymous FTP allows public access without requiring a username or password. The connection is made using the ‘anonymous’ username with an empty password (or optionally an email address as password).

Parameters:
  • server (str) – URL or INET address of FTP server (must support anonymous access)

  • dir (str) – Download directory name on the FTP server

  • filename (str, default='download.txt') – Download file name (same name used on server and locally)

  • verbose (bool, default=False) – True = command-line output on

Returns:

File is saved to the current working directory

Return type:

None

Raises:

Notes

Anonymous FTP Login: - Uses username: ‘anonymous’ (implicit in ftplib.FTP.login()) - Uses password: ‘’ (empty) or email address - Requires server to allow anonymous access - Common for public data repositories and archives