Download file containing this package.
        :param force: Force download even if it seems file already exists
        :return: Full path with filename of downloaded package file.
960627
def download(self, force=False):
        
        exists, dest_path = self._downloader.cache.exists_packed(package=self, pkg_path=self.packed_path,
                                                                 check_stat=not self._in_cache)
        unp_exists, unp_path = self._downloader.cache.exists_unpacked(package=self, pkg_path=self.unpacked_path)

        # Если архива нет, то и кешу доверять не стоит
        if not exists:
            unp_exists = False

        if exists and not self.packed_path:
            self.packed_path = dest_path

        if force or not exists:
            # _packed_path = self._packed_path
            dest_path_tmp = dest_path + ".tmp"
            if os.path.exists(dest_path_tmp):
                os.remove(dest_path_tmp)
            self._adapter.download_package(self._pkg, dest_path_tmp)
            os.rename(dest_path_tmp, dest_path)
            self.packed_path = dest_path
            # if not _packed_path:
            self._not_cached = True
        else:
            if unp_exists and not self.unpacked_path:
                self.unpacked_path = unp_path
                self._not_cached = False

        if self._not_cached and unp_exists:
            shutil.rmtree(unp_path, ignore_errors=True)

        return self.packed_path
497924
def upload(self, force=False):
        
        self.package and self.release
        try:
            return self.aserver_api.upload(self.username, self.project, self.version,
                                       basename(self.filepath), open(self.filepath, 'rb'),
                                       self.filepath.split('.')[-1])
        except errors.Conflict:
            if force:
                self.remove()
                return self.upload()
            else:
                msg = "Conflict: {} already exist in {}/{}".format(self.filepath,
                                                                   self.project,
                                                                   self.version)
                raise errors.BinstarError(msg)
889168
def download(url, directory, filename=None):
    
    if not filename:
        _, filename = os.path.split(url)
    directory = os.path.expanduser(directory)
    ensure_directory(directory)
    filepath = os.path.join(directory, filename)
    if os.path.isfile(filepath):
        return filepath
    print('Download', filepath)
    with urlopen(url) as response, open(filepath, 'wb') as file_:
        shutil.copyfileobj(response, file_)
    return filepath
1303424
def download(input, filename, format='sdf', overwrite=False, resolvers=None, **kwargs):
    
    kwargs['format'] = format
    if resolvers:
        kwargs['resolver'] = ",".join(resolvers)
    url = API_BASE+'/%s/file?%s' % (urlquote(input), urlencode(kwargs))
    try:
        servefile = urlopen(url)
        if not overwrite and os.path.isfile(filename):
            raise IOError("%s already exists. Use 'overwrite=True' to overwrite it." % filename)
        file = open(filename, "w")
        file.write(servefile.read())
        file.close()
    except urllib.error.HTTPError:
        # TODO: Proper handling of 404, for now just does nothing
        pass
1126166
def get_file(filename):
    ''''''
    destination = __DOWNLOAD_PARAMS['path']
    filepath = os.path.join(destination, filename)

    if not __is_current(filepath):

        if not os.path.exists(destination):
            os.makedirs(destination)

        url = 'ftp://ftp.ebi.ac.uk/pub/databases/chebi/' + \
            'Flat_file_tab_delimited/'
        urlretrieve(urlparse.urljoin(url, filename), filepath)
        urlcleanup()

    if filepath.endswith('.zip'):
        zfile = zipfile.ZipFile(filepath, 'r')
        filepath = os.path.join(destination, zfile.namelist()[0])
        zfile.extractall(destination)
    elif filepath.endswith('.gz'):
        unzipped_filepath = filepath[:-len('.gz')]

        if os.path.exists(unzipped_filepath) \
                and __is_current(unzipped_filepath):
            filepath = unzipped_filepath
        else:
            input_file = gzip.open(filepath, 'rb')
            filepath = os.path.join(destination, input_file.name[:-len('.gz')])
            output_file = open(filepath, 'wb')

            for line in input_file:
                output_file.write(line)

            input_file.close()
            output_file.close()

    return filepath
404461
def download(self, request, **kwargs):
        '''
        
        '''
        # method check to avoid bad requests
        self.method_check(request, allowed=['get'])
        # Must be done otherwise endpoint will be wide open
        self.is_authenticated(request)

        response = None
        file_item_name = kwargs.get('name', None)
        if file_item_name:
            filename_absolute = helpers.get_filename_absolute(file_item_name)
            if os.path.isfile(filename_absolute):
                response = serve(request, os.path.basename(filename_absolute), os.path.dirname(filename_absolute))
                response['Content-Disposition'] = 'attachment; filename="{}"'.format(
                    os.path.basename(filename_absolute))

        if not response:
            response = self.create_response(request, {'status': 'filename not specified'})

        return response
524033
def download_file(self, fname, output_dir):
    """"""
    if fname not in self.competition_files:  # pylint: disable=unsupported-membership-test
      raise ValueError("%s is not one of the competition's "
                       "files: %s" % (fname, self.competition_files))
    command = [
        "kaggle",
        "competitions",
        "download",
        "--file",
        fname,
        "--path",
        output_dir,
        "-c",
        self._competition_name,
    ]
    _run_kaggle_command(command, self._competition_name)
    return os.path.join(output_dir, fname)
1271201
def _downloaded_filename(self):
        
        # Peep doesn't support requirements that don't come down as a single
        # file, because it can't hash them. Thus, it doesn't support editable
        # requirements, because pip itself doesn't support editable
        # requirements except for "local projects or a VCS url". Nor does it
        # support VCS requirements yet, because we haven't yet come up with a
        # portable, deterministic way to hash them. In summary, all we support
        # is == requirements and tarballs/zips/etc.

        # TODO: Stop on reqs that are editable or aren't ==.

        # If the requirement isn't already specified as a URL, get a URL
        # from an index:
        link = self._link() or self._finder.find_requirement(self._req, upgrade=False)

        if link:
            lower_scheme = link.scheme.lower()  # pip lower()s it for some reason.
            if lower_scheme == 'http' or lower_scheme == 'https':
                file_path = self._download(link)
                return basename(file_path)
            elif lower_scheme == 'file':
                # The following is inspired by pip's unpack_file_url():
                link_path = url_to_path(link.url_without_fragment)
                if isdir(link_path):
                    raise UnsupportedRequirementError(
                        "%s: %s is a directory. So that it can compute "
                        "a hash, peep supports only filesystem paths which "
                        "point to files" %
                        (self._req, link.url_without_fragment))
                else:
                    copy(link_path, self._temp_path)
                    return basename(link_path)
            else:
                raise UnsupportedRequirementError(
                    "%s: The download link, %s, would not result in a file "
                    "that can be hashed. Peep supports only == requirements, "
                    "file:// URLs pointing to files (not folders), and "
                    "http:// and https:// URLs pointing to tarballs, zips, "
                    "etc." % (self._req, link.url))
        else:
            raise UnsupportedRequirementError(
                "%s: couldn't determine where to download this requirement from."
                % (self._req,))
189964
def download_jruby(jruby_version, force=false)
      dist = "#{Dir.home}/.jruby-jar"
      unless force || (File.exists?("#{dist}/jruby-complete-#{jruby_version}.jar") && File.size("#{dist}/jruby-complete-#{jruby_version}.jar") > 0)
        mkdir_p dist
        base_dir = Dir.pwd
        cd dist
        $stderr.puts "JRuby complete jar not found. Downloading... (May take awhile)"
        download(jruby_version)
        cd base_dir
      end
    end
226698
def http_download(url, target_path):
    
    r = requests.get(url, stream=True)
    with open(target_path, 'wb') as f:
        # shutil.copyfileobj(resp, f)
        for chunk in r.iter_content(chunk_size=1024):
            if chunk:
                f.write(chunk)
    return target_path
1316744
def fetch(force=False):
    
    try:
        # python 2
        from urllib2 import urlopen, HTTPError, URLError
    except ImportError:
        # python 3
        from urllib.request import urlopen, HTTPError, URLError

    if os.path.isdir(FIJI_ROOT) and not force:
        return
    elif not os.path.isdir(FIJI_ROOT):
        print('Fiji missing in %s' % FIJI_ROOT)

    if force:
        print('Deleting %s' % FIJI_ROOT)
        shutil.rmtree(FIJI_ROOT, ignore_errors=True)

    print('Downloading fiji from %s' % URL)
    try:
        req = urlopen(URL)
        try:
            size = int(req.info()['content-length'])
        except AttributeError:
            size = -1

        chunk = 512*1024
        fp = BytesIO()
        i = 0
        while 1:
            data = req.read(chunk)
            if not data:
                break
            fp.write(data)
            if size > 0:
                percent = fp.tell() // (size/100)
                msg = 'Downloaded %d percent      \r' % percent
            else:
                msg = 'Downloaded %d bytes\r' % fp.tell()
            sys.stdout.write(msg)
    except (HTTPError, URLError) as e:
        print('Error getting fiji: {}'.format(e))
        sys.exit(1)

    try:
        print('\nExtracting zip')
        z = ZipFile(fp)
        z.extractall(BIN_FOLDER)
        # move to Fiji-VERSION.app to easily check if it exists (upon fijibin upgrade)
        os.rename(EXTRACT_FOLDER, FIJI_ROOT)
    except (BadZipFile, IOError) as e:
        print('Error extracting zip: {}'.format(e))
        sys.exit(1)

    for path in BIN_NAMES.values():
        st = os.stat(path)
        os.chmod(path, st.st_mode | stat.S_IEXEC)
211019
def download(self, package_name):
        """"""
        if not package_name:
            ValueError('package_name required.')
        if self.is_dnf:
            cmd = 'dnf download {0}.{1}'.format(package_name, self.arch)
        else:
            cmd = 'yumdownloader {0}.{1}'.format(package_name, self.arch)
        try:
            Cmd.sh_e(cmd, stdout=subprocess.PIPE)
        except CmdError as e:
            for out in (e.stdout, e.stderr):
                for line in out.split('\n'):
                    if re.match(r'^No package [^ ]+ available', line) or \
                       re.match(r'^No Match for argument', line):
                        raise RemoteFileNotFoundError(
                            'Package {0} not found on remote'.format(
                                package_name
                            )
                        )
            raise e
868705
def download_file(self, src_uri, target):
        
        resource = self.get_resource_by_uri(src_uri)
        if not isinstance(resource, File):
            raise MediaFireError("Only files can be downloaded")

        quick_key = resource['quickkey']
        result = self.api.file_get_links(quick_key=quick_key,
                                         link_type='direct_download')
        direct_download = result['links'][0]['direct_download']

        # Force download over HTTPS
        direct_download = direct_download.replace('http:', 'https:')

        name = resource['filename']

        target_is_filehandle = True if hasattr(target, 'write') else False

        if not target_is_filehandle:
            if (os.path.exists(target) and os.path.isdir(target)) or \
                    target.endswith("/"):
                target = os.path.join(target, name)

            if not os.path.isdir(os.path.dirname(target)):
                os.makedirs(os.path.dirname(target))

            logger.info("Downloading %s to %s", src_uri, target)

        response = requests.get(direct_download, stream=True)
        try:
            if target_is_filehandle:
                out_fd = target
            else:
                out_fd = open(target, 'wb')

            checksum = hashlib.sha256()
            for chunk in response.iter_content(chunk_size=4096):
                if chunk:
                    out_fd.write(chunk)
                    checksum.update(chunk)

            checksum_hex = checksum.hexdigest().lower()
            if checksum_hex != resource['hash']:
                raise DownloadError("Hash mismatch ({} != {})".format(
                    resource['hash'], checksum_hex))

            logger.info("Download completed successfully")
        finally:
            if not target_is_filehandle:
                out_fd.close()
5172
def download_to(self, folder):
        '''
        
        '''
        urlretrieve(self.maven_url, os.path.join(folder, self.filename))
141968
def download_seq_file(self, outdir, force_rerun=False):
        """"""

        uniprot_fasta_file = download_uniprot_file(uniprot_id=self.id,
                                                   filetype='fasta',
                                                   outdir=outdir,
                                                   force_rerun=force_rerun)

        self.sequence_path = uniprot_fasta_file
972217
def download_file(self, *args, **kwargs):
        """"""
        return download_file(*args, **self._merge_overrides(**kwargs)).run()
1296111
def _get_path(fname: str) -> str:
    
    path = get_corpus_path(fname)
    if not path:
        download(fname)
        path = get_corpus_path(fname)
    return path