Beispiel #1
0
def download_file(url, output_directory, filename=None):
    if not filename:
        local_filename = os.path.join(output_directory, url.split('/')[-1])
    else:
        local_filename = os.path.join(output_directory, filename)
    dw = Download(url, des=local_filename, overwrite=True, )
    dw.download()
    return local_filename
Beispiel #2
0
def test_file_integrity():
    """
    Test the integrity of the downloaded file.

    We will test the 5MB.zip file which has a hash
    of `eb08885e3082037a12a42308c521fa3c`.
    """
    HASH = "eb08885e3082037a12a42308c521fa3c"

    download = Download(TEST_URL)
    download.download()

    # Once download is done, check the integrity
    _hash = md5(open("5MB.zip", "rb").read()).hexdigest()

    assert _hash == HASH, "Integrity check failed for 5MB.zip"

    # Remove the file now
    remove(download.basename)