Web

magna.util.web.download_file(url, path, md5=None, silent=False)

Downloads a file to disk, optionally validating the md5 hash.

Parameters
  • url (str) – The url to download from.

  • path (str) – The path to save the file to.

  • md5 (Optional[str, None]) – The expected md5 hash of the file.

  • silent (bool) – True if the progress should be supressed.

Raises

IOError – If the md5 hash doesn’t match.

Examples

Download the file at https://www.example.com/data.csv to /tmp/data.csv.

>>> download_file('https://www.example.com/data.csv', '/tmp/data.csv')