check_download_file

sunpy.util.net.check_download_file(filename, remotepath, download_dir, remotename=None, replace=False)[source] [edit on github]

Downloads a file from remotepath to localpath if it isn’t there.

This function checks whether a file with name filename exists in the location, localpath, on the user’s local machine. If it doesn’t, it downloads the file from remotepath.

Parameters:
  • filename (string) – Name of file.
  • remotepath (string) – URL of the remote location from which filename can be downloaded.
  • download_dir (string) – The files directory.
  • remotename ((optional) string) – filename under which the file is stored remotely. Default is same as filename.
  • replace ((optional) bool) – If True, file will be downloaded whether or not file already exists locally.

Examples

>>> from sunpy.util.net import check_download_file
>>> remotepath = "http://www.download_repository.com/downloads/"
>>> check_download_file("filename.txt", remotepath, download_dir='.')