def download(url, into='~/.cache/DeepFried2', saveas=None, desc=None, quiet=False):

    # Make sure the target folder exists.
    into = _os.path.expanduser(into)
    try:
        _os.makedirs(into)
    except FileExistsError:
        pass

    try:
        response = _urlopen(url, timeout=5)
    except (_URLError, _timeout):
        # No internet connection is available, so just trust the file if it's already there.
        saveas = saveas or _os.path.basename(url)
        target = _os.path.join(into, saveas)

        if not _os.path.isfile(target):
            raise FileNotFoundError(target)
        if not quiet:
            print("No internet connection; using untrusted cached file at {}".format(target))
        return target

    # We do have an internet connection and were able to get to the URL.
    saveas = saveas or _httpfilename(response) or _os.path.basename(url)
    target = _os.path.join(into, saveas)

    leng = int(_getheader(response, 'Content-Length', 0))
    # assert leng == response.length, "Huh, looks like we didn't get all data. Maybe retry?"

    # In case the file's already there, we may avoid re-downloading it.
    if _os.path.isfile(target):
        # First, check if we got ETag which is a widely-supported checksum-ish HTTP header.
        try:
            with open(target + '.etag', 'r') as f:
                etag = f.read()
            if _getheader(response, 'ETag') == etag:
                return target
        except FileNotFoundError:
            pass

        # Alternatively, check whether the file has the same size.
        if _os.path.getsize(target) == leng:
            # If there's no last-modified header, just trust it blindly.
            servertime = _eutils.parsedate_tz(_getheader(response, 'Last-Modified'))
            if servertime is None:
                return target
            else:
                # But if there is, we may also check that.
                if _os.path.getmtime(target) >= _eutils.mktime_tz(servertime):
                    return target

    # TODO: Use progressbar from example utils.
    if not quiet:
        desc = desc or '{} to {}'.format(url, target)
        _sys.stdout.write('Downloading {}: {}k/{}k (:.2%)'.format(desc, 0, leng//1024, 0))
        _sys.stdout.flush()

    with open(target, 'wb+') as f:
        while f.tell() < leng:
            f.write(response.read(1024*8))
            if not quiet:
                _sys.stdout.write('\rDownloading {}: {}k/{}k ({:.2%})'.format(desc, f.tell()//1024, leng//1024, float(f.tell())/leng))
                _sys.stdout.flush()
    if not quiet:
        print("")

    # Finally, if present, save the ETag for later checking.
    etag = _getheader(response, 'ETag')
    if etag is not None:
        with open(target + '.etag', 'w+') as f:
            f.write(etag)

    return target
The view function for requesting fs for admin
dataset/ETHPy150Open lucasb-eyer/DeepFried2/DeepFried2/zoo/download.py/download--crossover with--dataset/ETHPy150Open fp7-ofelia/ocf/optin_manager/src/python/openflow/optin_manager/admin_manager/views.py/admin_reg_fs_by_file