(url, root, filename=None, md5=None)
Download a file from a url and place it in root.
    Args:
        url (str): URL to download file from
        root (str): Directory to place downloaded file in
        filename (str): Name to save the file under. If None, use the basename of the URL
        md5 (str): MD5 checksum of the download. If None, do not check
Download a file from a url and place it in root.
    Args:
        url (str): URL to download file from
        root (str): Directory to place downloaded file in
        filename (str): Name to save the file under. If None, use the basename of the URL
        md5 (str): MD5 checksum of the download. If None, do not check
Download a file from a url and place it in root . Args : url ( str ) : URL to download file from root ( str ) : Directory to place downloaded file in filename ( str ) : Name to save the file under . If None use the basename of the URL md5 ( str ) : MD5 checksum of the download . If None do not check
def download_url(url, root, filename=None, md5=None):
    """Download a file from a url and place it in root.
    Args:
        url (str): URL to download file from
        root (str): Directory to place downloaded file in
        filename (str): Name to save the file under. If None, use the basename of the URL
        md5 (str): MD5 checksum of the download. If None, do not check
    """
    from six.moves import urllib

    root = os.path.expanduser(root)
    if not filename:
        filename = os.path.basename(url)
    fpath = os.path.join(root, filename)

    makedir_exist_ok(root)

    # downloads file
    if os.path.isfile(fpath) and check_integrity(fpath, md5):
        print('Using downloaded and verified file: ' + fpath)
    else:
        try:
            print('Downloading ' + url + ' to ' + fpath)
            urllib.request.urlretrieve(
                url, fpath,
                reporthook=gen_bar_updater(tqdm(unit='B', unit_scale=True))
            )
        except OSError:
            if url[:5] == 'https':
                url = url.replace('https:', 'http:')
                print('Failed download. Trying https -> http instead.'
                      ' Downloading ' + url + ' to ' + fpath)
                urllib.request.urlretrieve(
                    url, fpath,
                    reporthook=gen_bar_updater(tqdm(unit='B', unit_scale=True))
                )
def download_url ( url , root , filename = None , md5 = None ) : from six . moves import urllib root = os . path . expanduser ( root ) if not filename : filename = os . path . basename ( url ) fpath = os . path . join ( root , filename ) makedir_exist_ok ( root ) # downloads file if os . path . isfile ( fpath ) and check_integrity ( fpath , md5 ) : print ( 'Using downloaded and verified file: ' + fpath ) else : try : print ( 'Downloading ' + url + ' to ' + fpath ) urllib . request . urlretrieve ( url , fpath , reporthook = gen_bar_updater ( tqdm ( unit = 'B' , unit_scale = True ) ) ) except OSError : if url [ : 5 ] == 'https' : url = url . replace ( 'https:' , 'http:' ) print ( 'Failed download. Trying https -> http instead.' ' Downloading ' + url + ' to ' + fpath ) urllib . request . urlretrieve ( url , fpath , reporthook = gen_bar_updater ( tqdm ( unit = 'B' , unit_scale = True ) ) )