pooch.FTPDownloader

pooch.FTPDownloader#

class pooch.FTPDownloader(port=21, username='anonymous', password='', account='', timeout=None, progressbar=False, chunk_size=1024)[source]#

Download manager for fetching files over FTP.

When called, downloads the given file URL into the specified local file. Uses the ftplib module to manage downloads.

Use with pooch.Pooch.fetch or pooch.retrieve to customize the download of files (for example, to use authentication or print a progress bar).

Parameters:
  • port (int) – Port used for the FTP connection.

  • username (str) – User name used to login to the server. Only needed if the server requires authentication (i.e., no anonymous FTP).

  • password (str) – Password used to login to the server. Only needed if the server requires authentication (i.e., no anonymous FTP). Use the empty string to indicate no password is required.

  • account (str) – Some servers also require an “account” name for authentication.

  • timeout (int) – Timeout in seconds for ftp socket operations, use None to mean no timeout.

  • progressbar (bool) – If True, will print a progress bar of the download to standard error (stderr). Requires tqdm to be installed. Custom progress bars are not yet supported.

  • chunk_size (int) – Files are streamed chunk_size bytes at a time instead of loading everything into memory at one. Usually doesn’t need to be changed.

Methods Summary

FTPDownloader.__call__(url, output_file, pooch)

Download the given URL over FTP to the given output file.


FTPDownloader.__call__(url, output_file, pooch, check_only=False)[source]#

Download the given URL over FTP to the given output file.

Parameters:
  • url (str) – The URL to the file you want to download.

  • output_file (str or file-like object) – Path (and file name) to which the file will be downloaded.

  • pooch (Pooch) – The instance of Pooch that is calling this method.

  • check_only (bool) – If True, will only check if a file exists on the server and without downloading the file. Will return True if the file exists and False otherwise.

Returns:

availability (bool or None) – If check_only==True, returns a boolean indicating if the file is available on the server. Otherwise, returns None.