Download, unzip and delete. Warning: function with strong side effects!

    Returns downloaded data.

    :param str url: url from which data should be donloaded
    :param destination: destination to which data should be downloaded
493439
def downzip(url, destination="./sample_data/"):
    

    # url = "http://147.228.240.61/queetech/sample-data/jatra_06mm_jenjatra.zip"
    logmsg = "downloading from '" + url + "' to '" + destination + "'"
    print(logmsg)
    logger.info(logmsg)
    tmp_filename = url[url.rfind("/") + 1 :]
    # tmp_filename = "tmp.zip"
    # urllibr.urlretrieve(url, zip_file_name)
    from . import network

    network.download_file(url, destination, filename=tmp_filename)
    zip_file_name = os.path.join(destination, tmp_filename)
    base, ext = op.splitext(tmp_filename)
    # print(ext)
    # print(tmp_filename)
    if ext in (".zip"):
        unzip_recursive(zip_file_name)
478174
def get_raw_data_from_url(pdb_id, reduced=False):
    "
    url = get_url(pdb_id,reduced)
    request = urllib2.Request(url)
    request.add_header('Accept-encoding', 'gzip')
    response = urllib2.urlopen(request)
    if response.info().get('Content-Encoding') == 'gzip':
        data = ungzip_data(response.read())
    else:
        data = response.read()
    return _unpack(data)
409566
def download(self, url, save_path, header={}, redownload=False):
        
        if save_path is None:
            logger.error("save_path cannot be None")
            return None

        # Get headers of current web driver
        header = self.get_headers()
        if len(header) > 0:
            # Add more headers if needed
            header.update(header)

        logger.debug("Download {url} to {save_path}".format(url=url, save_path=save_path))

        save_location = cutil.norm_path(save_path)
        if redownload is False:
            # See if we already have the file
            if os.path.isfile(save_location):
                logger.debug("File {save_location} already exists".format(save_location=save_location))
                return save_location

        # Create the dir path on disk
        cutil.create_path(save_location)

        if url.startswith('//'):
            url = "http:" + url
        try:
            with urllib.request.urlopen(urllib.request.Request(url, headers=header)) as response,\
            open(save_location, 'wb') as out_file:
                data = response.read()
                out_file.write(data)

        except urllib.error.HTTPError as e:
            save_location = None
            # We do not need to show the user 404 errors
            if e.code != 404:
                logger.exception("Download Http Error {url}".format(url=url))

        except Exception:
            save_location = None
            logger.exception("Download Error: {url}".format(url=url))

        return save_location
660800
def destination(dest)
      # The url needs to be unescaped in order to preserve the correct filename
      path = File.join(dest, @dir, CGI.unescape(url))

      if ext == '.html' && _localization_original_url !~ /\.html\z/
        path.sub!(Localization::LANG_END_RE, '')
        File.join(path, "index#{ext}#{@lang_ext}")
      else
        path
      end
    end
1167686
def download(source, sink=None):
    
    try:
        from urllib.request import urlretrieve  # Python 3
    except ImportError:
        from urllib import urlretrieve  # Python 2
    if sink is None:
        sink = os.path.abspath(os.path.split(source)[1])
    urlretrieve(source, sink)
    return sink
171947
def downloadFile(url,outfile=None): 
    '''  '''
    if not outfile:
        outfile = url.split('/')[-1]
    r = requests.get(url, stream=True)
    with open(outfile, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024): 
            if chunk: 
                f.write(chunk)
    return outfile
720876
def zip(self, destination: typing.Union[str, Path] = None, encode: bool = True) -> str:
        
        if encode:
            self._encode()

        if destination is None:
            destination_path = self.miz_path.parent.joinpath(f'{self.miz_path.stem}_EMIZ.miz')
        else:
            destination_path = elib.path.ensure_file(destination, must_exist=False)

        LOGGER.debug('zipping mission to: %s', destination_path)

        destination_path.write_bytes(dummy_miz)

        with ZipFile(str(destination_path), mode='w', compression=8) as zip_file:

            for root, _, items in os.walk(self.temp_dir.absolute()):
                for item in items:
                    item_abs_path = Path(root, item).absolute()
                    item_rel_path = Path(item_abs_path).relative_to(self.temp_dir)
                    zip_file.write(item_abs_path, arcname=item_rel_path)

        return str(destination_path)
1055572
def uncompress_files(original, destination):
    
    with zipfile.ZipFile(original) as zips:
        extract_path = os.path.join(destination)
        zips.extractall(extract_path)
878584
def _DownloadUrl(self, url, dest_dir):
    
    dest_file = tempfile.NamedTemporaryFile(dir=dest_dir, delete=False)
    dest_file.close()
    dest = dest_file.name

    self.logger.info('Downloading url from %s to %s.', url, dest)
    try:
      urlretrieve.urlretrieve(url, dest)
      return dest
    except (httpclient.HTTPException, socket.error, urlerror.URLError) as e:
      self.logger.warning('Could not download %s. %s.', url, str(e))
    except Exception as e:
      self.logger.warning('Exception downloading %s. %s.', url, str(e))
    return None
440150
def downloadFileFromUrl(self, url):
		""""""
		fullurl = self.baseUrl + url
		try:
			urlobj = urllib2.urlopen(fullurl)
			contents = urlobj.read()
		except urllib2.HTTPError, e:
			self.printd("HTTP error:", e.code, url)
			return None
		except urllib2.URLError, e:
			self.printd("URL error:", e.code, url)
			return None
		self.printd("Fetched '%s' (size %d bytes)" % (fullurl, len(contents)))
		return contents
420318
def check(self, url: str) -> Optional[dict]:
        
        data = self.data.get(url)
        if data:
            data = self._check_expiration(url, data)
        return data.data if data else None
50957
def download(self,
                 url,
                 dest_path=None):
        
        if os.path.exists(dest_path):
            os.remove(dest_path)

        resp = get(url, stream=True)
        size = int(resp.headers.get("content-length"))
        label = "Downloading {filename} ({size:.2f}MB)".format(
            filename=os.path.basename(dest_path),
            size=size / float(self.chunk_size) / self.chunk_size
        )

        with open_file(dest_path, 'wb') as file:
            content_iter = resp.iter_content(chunk_size=self.chunk_size)
            with progressbar(content_iter,
                             length=size / self.chunk_size,
                             label=label) as bar:
                for chunk in bar:
                    if chunk:
                        file.write(chunk)
                        file.flush()
843883
def download(cls, url, filename=None):
        
        return utility.download(url, cls.directory(), filename)
1243705
public Response download(String url, File destination, String... headers) throws IOException {
		try (Response resp = response(url, headers)) {
			if (resp.isSuccessful()) {
				try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) {
					resp.body().source().readAll(sink);
				}
			}
			return resp;
		}
	}
913384
def extract(self, destination):
        

        if os.path.exists(destination):
            raise OSError(20, 'Destination exists', destination)

        self.__extract_directory(
            '.',
            self.files['files'],
            destination
        )
639413
def _download_from_url(self, url):
        
        ext = get_file_extension(url)
        if "?" in url:
            ext = get_file_extension(os.path.splitext(url.split("?")[0]))
        filepath = "/tmp/%s.%s" % (uuid.uuid4().hex, ext)
        request.urlretrieve(url, filepath)
        return filepath
21787
def unzip(source_file, destination_dir):
    
    with zipfile.ZipFile(source_file) as zf:
        zf.extractall(destination_dir)