Download zip archive and extract it to temporary directory.
544445
def download_and_extract_to_mkdtemp(bucket, key, session=None):
    """"""
    if session:
        s3_client = session.client('s3')
    else:
        s3_client = boto3.client('s3')
    transfer = S3Transfer(s3_client)

    filedes, temp_file = tempfile.mkstemp()
    os.close(filedes)
    transfer.download_file(bucket, key, temp_file)

    output_dir = tempfile.mkdtemp()
    zip_ref = zipfile.ZipFile(temp_file, 'r')
    zip_ref.extractall(output_dir)
    zip_ref.close()
    os.remove(temp_file)
    return output_dir
804535
def download(url, dest):
    """"""
    path = os.path.join(dest, url.split('/')[-1])
    r = requests.get(url, stream=True)
    r.raise_for_status()
    with open(path, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024):
            if chunk:
                f.write(chunk)
    return path
1102414
def downloadArchiveAction(self, request, queryset):
        '''
        
        '''
        output = io.BytesIO()
        z = zipfile.ZipFile(output, 'w')

        for sub in queryset:
            sub.add_to_zipfile(z)

        z.close()
        # go back to start in ZIP file so that Django can deliver it
        output.seek(0)
        response = HttpResponse(
            output, content_type="application/x-zip-compressed")
        response['Content-Disposition'] = 'attachment; filename=submissions.zip'
        return response
5172
def download_to(self, folder):
        '''
        
        '''
        urlretrieve(self.maven_url, os.path.join(folder, self.filename))
280547
def extract(self, destination):
        """"""
        with zipfile.ZipFile(self.archive, 'r') as zip_ref:
            zip_ref.extractall(destination)
359477
def extract(self):
        """"""
        if self.files:
            return dict((f, self.read_file(f)) for f in self.files)
        else:
            raise RuntimeError("Can't extract whole archive without listfile.")
1061314
def extract_archive(self, client, archive_path, extract_path=None):
        """"""
        try:
            out = ipa_utils.extract_archive(client, archive_path, extract_path)
        except Exception as error:
            raise IpaCloudException(
                'Failed to extract archive, "{0}": {1}.'.format(
                    archive_path, error
                )
            )

        else:
            self._write_to_log(out)
121142
def zipfiles(fnames, archive, mode='w', log=lambda msg: None, cleanup=False):
    
    prefix = len(os.path.commonprefix([os.path.dirname(f) for f in fnames]))
    with zipfile.ZipFile(
            archive, mode, zipfile.ZIP_DEFLATED, allowZip64=True) as z:
        for f in fnames:
            log('Archiving %s' % f)
            z.write(f, f[prefix:])
            if cleanup:  # remove the zipped file
                os.remove(f)
    log('Generated %s' % archive)
    return archive
1038775
def extract_rar (archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    cmdlist = [cmd, 'x']
    if not interactive:
        cmdlist.extend(['-p-', '-y'])
    cmdlist.extend(['--', os.path.abspath(archive)])
    return (cmdlist, {'cwd': outdir})
347689
def from_zip(cls, src='/tmp/app.zip', dest='/app'):
    
    try:
      zf = zipfile.ZipFile(src, 'r')
    except FileNotFoundError:
      raise errors.InvalidPathError(src)
    except zipfile.BadZipFile:
      raise errors.InvalidZipFileError(src)
    [zf.extract(file, dest) for file in zf.namelist()]
    zf.close()
    return cls.from_path(dest)
330464
def download():
    """"""
    url = "http://download.geonames.org/export/dump/cities1000.zip"
    logging.info("Download cities from %s", url)

    if not os.path.exists(MISC_PATH):
        os.makedirs(MISC_PATH)
    zip_path = os.path.join(MISC_PATH, "cities1000.zip")
    urlretrieve(url, zip_path)
    with zipfile.ZipFile(zip_path, "r") as z:
        z.extractall(MISC_PATH)
881274
def extract_zip(self, suffix, path='.'):
        
        zip_fd, zip_fn = tempfile.mkstemp(prefix='fuzzfetch-', suffix='.zip')
        os.close(zip_fd)
        try:
            _download_url(self.artifact_url(suffix), zip_fn)
            LOG.info('.. extracting')
            with zipfile.ZipFile(zip_fn) as zip_fp:
                for info in zip_fp.infolist():
                    _extract_file(zip_fp, info, path)
        finally:
            os.unlink(zip_fn)
1290188
def extract_archive(archive, verbosity=0, outdir=None, program=None, interactive=True):
    """"""
    util.check_existing_filename(archive)
    if verbosity >= 0:
        util.log_info("Extracting %s ..." % archive)
    return _extract_archive(archive, verbosity=verbosity, interactive=interactive, outdir=outdir, program=program)
550532
def extract(self, destination):
        """"""
        with tarfile.open(self.archive, 'r:') as tar:
            tar.extractall(path=destination)
190209
def from_archive(archive_filename, py_interpreter=sys.executable):
    
    with _extract_to_tempdir(archive_filename) as root_dir:
        data = _setup_py_run_from_dir(root_dir, py_interpreter)
    return data
991032
def extract_zip(fileobj):
    """"""
    archive = zipfile.ZipFile(fileobj, mode='r')
    filenames = archive.namelist()

    for src_name, dst_name in filter_tzfiles(filenames):
        modified = archive.getinfo(src_name).date_time
        bytes = archive.read(src_name)

        yield dst_name, modified, bytes
300643
def extract_tar (archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    cmdlist = [cmd, '--extract']
    add_tar_opts(cmdlist, compression, verbosity)
    cmdlist.extend(["--file", archive, '--directory', outdir])
    return cmdlist