Run the FTP RETR command, and download the file

        :param filename: Name of the file to download
347610
def retrieve(self, filename):
        
        logger.debug('Sending FTP retr command. Filename: {}'.format(filename))
        self.client.retrbinary('RETR {}'.format(filename), self._save_file)
1104577
def download_as_zip(name, filename):
    
    location = list(IPList.objects.filter(name))
    if location:
        iplist = location[0]
        return iplist.download(filename=filename)
560233
def download(url: str, filename: str,
             skip_cert_verify: bool = True) -> None:
    
    log.info("Downloading from {} to {}", url, filename)

    # urllib.request.urlretrieve(url, filename)
    # ... sometimes fails (e.g. downloading
    # https://www.openssl.org/source/openssl-1.1.0g.tar.gz under Windows) with:
    # ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)  # noqa
    # ... due to this certificate root problem (probably because OpenSSL
    #     [used by Python] doesn't play entirely by the same rules as others?):
    # https://stackoverflow.com/questions/27804710
    # So:

    ctx = ssl.create_default_context()  # type: ssl.SSLContext
    if skip_cert_verify:
        log.debug("Skipping SSL certificate check for " + url)
        ctx.check_hostname = False
        ctx.verify_mode = ssl.CERT_NONE
    with urllib.request.urlopen(url, context=ctx) as u, open(filename,
                                                             'wb') as f:  # noqa
        f.write(u.read())
948121
def download_file(url, filename):
    """"""
    r = _get_requests_session().get(url, stream=True)
    if not r.ok:
        raise IOError("Unable to download file")

    with open(filename, "wb") as f:
        f.write(r.content)
1139010
public static void downloadFile(String hostname, String username,
			String password, String remoteSource, String localDestination)
			throws Exception {
		FTPClient ftp = new FTPClient();
		ftp.connect(hostname);
		ftp.login(username, password);
		ftp.setFileType(FTP.BINARY_FILE_TYPE);
		ftp.enterLocalPassiveMode();
		FileOutputStream fos = new FileOutputStream(localDestination);
		ftp.retrieveFile(remoteSource, fos);
		ftp.logout();
		ftp.disconnect();
	}
286093
def save(self, filename):
        
        clibrebound.reb_output_binary(byref(self), c_char_p(filename.encode("ascii")))
463326
def open(self, filename, mode='r', bufsize=-1):
        
        sftp_client = self.open_sftp()
        return sftp_client.open(filename, mode, bufsize)
99049
def download(url, file_name):
    r = requests.get(url, stream=True)
    file_size = int(r.headers['Content-length'])
    '''
    
    '''
    file_exists = False
    if os.path.isfile(file_name):
        local_file_size = os.path.getsize(file_name)
        if local_file_size == file_size:
            sha1_file = file_name + '.sha1'
            if os.path.isfile(sha1_file):
                print('sha1 found')
                with open(sha1_file) as f:
                    expected_sha1 = f.read()
                BLOCKSIZE = 65536
                sha1 = hashlib.sha1()
                with open(file_name) as f:
                    buff = f.read(BLOCKSIZE)
                    while len(buff) > 0:
                        sha1.update(buff)
                        buff = f.read(BLOCKSIZE)
                if expected_sha1 == sha1:
                    file_exists = True
                else:
                    print("File corrupt. Downloading again.")
                    os.remove(file_name)
            else:
                file_exists = True
        else:
            print("File corrupt. Downloading again.")
            os.remove(file_name)
    if not file_exists:
        factor = int(math.floor(math.log(file_size) / math.log(1024)))
        display_file_size = str(file_size / 1024 ** factor) + \
            ['B', 'KB', 'MB', 'GB', 'TB', 'PB'][factor]
        print("Source: " + url)
        print("Destination " + file_name)
        print("Size: " + display_file_size)
        file_size_dl = 0
        block_sz = 8192
        f = open(file_name, 'wb')
        pbar = ProgressBar(file_size)
        for chunk in r.iter_content(chunk_size=block_sz):
            if not chunk:
                continue
            chunk_size = len(chunk)
            file_size_dl += chunk_size
            f.write(chunk)
            pbar.update(chunk_size)
            # status = r"%10d  [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
            # status = status + chr(8)*(len(status)+1)
            # print(status)
        f.close()
    else:
        print("File already exists - " + file_name)
        return True
464897
def open_readable(self, name):
        
        # print("FTP open_readable({})".format(name))
        assert compat.is_native(name)
        out = SpooledTemporaryFile(max_size=self.MAX_SPOOL_MEM, mode="w+b")
        self.ftp.retrbinary(
            "RETR {}".format(name), out.write, FtpTarget.DEFAULT_BLOCKSIZE
        )
        out.seek(0)
        return out
815576
def _read_file(self, filename):
        
        with open(filename, 'r') as stream:
            return self._read_stream(stream=stream)
147435
def _download_file(url, local_filename):
    '''
    
    '''
    response = requests.get(url, stream=True)
    with open(local_filename, 'wb') as outfile:
        for chunk in response.iter_content(chunk_size=1024):
            if chunk:  # filter out keep-alive new chunks
                outfile.write(chunk)
559137
def do_file(self, filename):
        
        with open(filename, "r") as infile:
            self._run_cmd(infile.read())
413470
def download(self, filename, format='sdf', overwrite=False, resolvers=None, **kwargs):
        
        download(self.input, filename, format, overwrite, resolvers, **kwargs)
1238278
def parsefile(self, filename):
        
        with open(filename, 'rb') as fd:
            return self.parse(fd.read())
879866
def download_file(cls, url, local_file_name=None, force=False, chunk_size=1024):
        

        local_file_name = local_file_name if local_file_name else url.split('/')[-1]
        filepath = os.path.join(cls.data_path, local_file_name)

        if not os.path.exists(filepath) or force:
            try:
                headers = requests.head(url, allow_redirects=True).headers
                length = headers.get('Content-Length')

                logger.info("Starting download of {} file with {} bytes ...".format(url, length))

                widgets = [
                    'Downloading file please wait...', progressbar.Percentage(),
                    ' ', progressbar.Bar(),
                    ' ', progressbar.ETA(),
                    ' ', progressbar.FileTransferSpeed(),
                ]
                bar = progressbar.ProgressBar(widgets=widgets, max_value=int(length) + chunk_size).start()

                r = requests.get(url, stream=True)

                with open(filepath, 'wb') as f:
                    total_chunk = 0

                    for chunk in r.iter_content(chunk_size):
                        if chunk:
                            f.write(chunk)
                            total_chunk += chunk_size
                            bar.update(total_chunk)

                bar.finish()

            except:
                if os.path.exists(filepath):
                    os.remove(filepath)

                raise

        return filepath
966556
def download_file(self, url):
        
        response = requests.get(url, stream=True)
        response.raise_for_status()
        return (int(response.headers.get('content-length', 0)), response)
650940
def download(self, url, file):
        
        if isinstance(file, str) or isinstance(file, unicode):
            file = open(file, 'wb')
        webclient = self.dupe()
        webclient.request('GET', url)
        rsp = webclient.getresponse()
        self._currdl = rsp
        self._dlfile = file
        for chunk in iter(lambda: rsp.read(16384), ''):
            file.write(chunk)
        self._currdl = None
        file.close()