def _download_file_from_drive(filename, url):  # pragma: no cover
    """ Download filename from google drive unless it's already in directory.

    Args:
        filename (str): Name of the file to download to (do nothing if it already exists).
        url (str): URL to download from.
    """
    confirm_token = None

    # Since the file is big, drive will scan it for virus and take it to a
    # warning page. We find the confirm token on this page and append it to the
    # URL to start the download process.
    confirm_token = None
    session = requests.Session()
    response = session.get(url, stream=True)
    for k, v in response.cookies.items():
        if k.startswith("download_warning"):
            confirm_token = v

    if confirm_token:
        url = url + "&confirm=" + confirm_token

    logger.info("Downloading %s to %s" % (url, filename))

    response = session.get(url, stream=True)
    # Now begin the download.
    chunk_size = 16 * 1024
    with open(filename, "wb") as f:
        for chunk in response.iter_content(chunk_size):
            if chunk:
                f.write(chunk)

    # Print newline to clear the carriage return from the download progress
    statinfo = os.stat(filename)
    logger.info("Successfully downloaded %s, %s bytes." % (filename, statinfo.st_size))
def _download_file_from_drive ( filename , url ) : confirm_token = None confirm_token = None session = requests . Session ( ) response = session . get ( url , stream = True ) for k , v in response . cookies . items ( ) : if k . startswith ( "download_warning" ) : confirm_token = v if confirm_token : url = url + "&confirm=" + confirm_token logger . info ( "Downloading %s to %s" % ( url , filename ) ) response = session . get ( url , stream = True ) chunk_size = 16 * 1024 with open ( filename , "wb" ) as f : for chunk in response . iter_content ( chunk_size ) : if chunk : f . write ( chunk ) statinfo = os . stat ( filename ) logger . info ( "Successfully downloaded %s, %s bytes." % ( filename , statinfo . st_size ) )
Download filename from google drive unless it's already in directory.

    Args:
        filename (str): Name of the file to download to (do nothing if it already exists).
        url (str): URL to download from.