lair.records.ftp_download#

lair.records.ftp_download(host, paths, download_dir, username='anonymous', password='', prefix=None, pattern=None)[source]#

Recursively download files from an FTP server.

Parameters:
  • host (str) – The FTP server host.

  • paths (str | list[str]) – The path(s) to download from the FTP server.

  • download_dir (str) – The local directory to download files to.

  • username (str, optional) – The username to use for the FTP server. Defaults to ‘anonymous’.

  • password (str, optional) – The password to use for the FTP server. Defaults to ‘’.

  • prefix (str, optional) – The common prefix to use for the local directory structure. Defaults to None. With None, each path is saved under its own name in download_dir (a folder keeps its name and what is below it). With a prefix, the remote folders below the prefix are kept. With an empty string, the whole remote path is recreated.

  • pattern (str, optional) – Only download files whose remote path matches. With wildcards (*, ?, [) it is a glob against the full remote path (e.g. '*2015-06*.nc'); otherwise any path containing it matches. Defaults to None (all files).

Returns:

bool – True when the download finishes. A failed transfer raises.

See also

wget_download

The same for URLs.

lair.noaa.CarbonTracker.download

Calls it with NOAA’s CarbonTracker folders.

lair.noaa.GMLData.download

Calls it with NOAA GML’s data folders.

Examples

>>> from lair.records import ftp_download
>>> ftp_download(
...     "ftp.gml.noaa.gov", "user/thoning/ccgcrv/ccg_filter.zip", "downloads"
... )
True