Store a distribution archive in all of the available caches.

        :param requirement: A :class:`.Requirement` object.
        :param handle: A file-like object that provides access to the
                       distribution archive.
496120
def put(self, requirement, handle):
        
        filename = self.generate_filename(requirement)
        for backend in list(self.backends):
            handle.seek(0)
            try:
                backend.put(filename, handle)
            except CacheBackendDisabledError as e:
                logger.debug("Disabling %s because it requires configuration: %s", backend, e)
                self.backends.remove(backend)
            except Exception as e:
                logger.exception("Disabling %s because it failed: %s", backend, e)
                self.backends.remove(backend)
666852
public function cache($handle)
    {
        $fileID = $this->getCacheID();
        $storage = Storage::disk($this->cache_disk);
        $storage->put(
            $this->generateCacheFilePath($fileID, true),
            $handle->encode($this->extension(), config('images.image_quality', 90))
        );
    }
1320837
function zipRequirements() {
  const rootZip = new JSZip();
  const src = path.join('.serverless', 'requirements');
  const runtimepath = 'python';

  return addTree(rootZip.folder(runtimepath), src).then(() =>
    writeZip(rootZip, path.join('.serverless', 'pythonRequirements.zip'))
  );
}
745765
def __get_handle_record_if_necessary(self, handle, handlerecord_json):
        '''
        

        '''
        if handlerecord_json is None:
            handlerecord_json = self.retrieve_handle_record_json(handle)
        else:
            if handle != handlerecord_json['handle']:
                handlerecord_json = self.retrieve_handle_record_json(handle)
        return handlerecord_json
769474
def archive(self):
        
        ids = self.rpc_model.search(self.domain, context=self.context)
        if ids:
            self.rpc_model.write(ids, {'active': False})
229892
def archive(self, repo_slug=None, format='zip', prefix=''):
        
        prefix = '%s'.lstrip('/') % prefix
        self._get_files_in_dir(repo_slug=repo_slug, dir='/')
        if self.bitbucket.repo_tree:
            with NamedTemporaryFile(delete=False) as archive:
                with ZipFile(archive, 'w') as zip_archive:
                    for name, file in self.bitbucket.repo_tree.items():
                        with NamedTemporaryFile(delete=False) as temp_file:
                            temp_file.write(file.encode('utf-8'))
                        zip_archive.write(temp_file.name, prefix + name)
            return (True, archive.name)
        return (False, 'Could not archive your project.')
807674
def store(bank, key, data, cachedir):
    '''
    
    '''
    base = os.path.join(cachedir, os.path.normpath(bank))
    try:
        os.makedirs(base)
    except OSError as exc:
        if exc.errno != errno.EEXIST:
            raise SaltCacheError(
                'The cache directory, {0}, could not be created: {1}'.format(
                    base, exc
                )
            )

    outfile = os.path.join(base, '{0}.p'.format(key))
    tmpfh, tmpfname = tempfile.mkstemp(dir=base)
    os.close(tmpfh)
    try:
        with salt.utils.files.fopen(tmpfname, 'w+b') as fh_:
            fh_.write(__context__['serial'].dumps(data))
        # On Windows, os.rename will fail if the destination file exists.
        salt.utils.atomicfile.atomic_rename(tmpfname, outfile)
    except IOError as exc:
        raise SaltCacheError(
            'There was an error writing the cache file, {0}: {1}'.format(
                base, exc
            )
        )
589357
def requirements(self):
        
        cache = apt.cache.Cache()
        for pkg in self.pkgs_required:
            try:
                pkg = cache[pkg]
                if not pkg.is_installed:
                    try:
                        pkg.mark_install()
                        cache.commit()
                    except LockFailedException as lfe:
                        logging.error(
                            'Errore "{}" probabilmente l\'utente {} non ha i '
                            'diritti di amministratore'.format(lfe,
                                                               self.username))
                        raise lfe
                    except Exception as e:
                        logging.error('Errore non classificato "{}"'.format(e))
                        raise e
            except KeyError:
                logging.error('Il pacchetto "{}" non e\' presente in questa'
                              ' distribuzione'.format(pkg))
133376
def create_required_directories(self):
        """"""
        required = (self.CACHE_DIR,
                    self.LOG_DIR,
                    self.OUTPUT_DIR,
                    self.ENGINEER.JINJA_CACHE_DIR,)

        for folder in required:
            ensure_exists(folder, assume_dirs=True)
461094
def load_dependencies(req, history=None):
    
    if history is None:
        history = set()
    dist = pkg_resources.get_distribution(req)
    spec = dict(
        requirement=str(req),
        resolved=str(dist),
    )
    if req not in history:
        # traverse into children
        history.add(req)
        extras = parse_extras(req)
        depends = [
            load_dependencies(dep, history=history)
            for dep in dist.requires(extras=extras)
        ]
        if depends:
            spec.update(depends=depends)
    return spec
457422
private void executeArchive() {
        for (AbstractArchiveJob archiveJob : jobs) {
            archiveJob.setArchiveDateDiff(extractArchiveDateCount(archiveEnv.getDatePattern()));
            archiveJob.setPath(archiveEnv.getDirPath());
            archiveJob.setCompressionExtention(archiveEnv.getCompression().getExtention());
            archiveJob.archive();
        }
    }
1144356
def fetch_archive(savedir, url, fname, force=False):
    """"""
    dest = pjoin(savedir, fname)
    if os.path.exists(dest) and not force:
        info("already have %s" % fname)
        return dest
    info("fetching %s into %s" % (url, savedir))
    if not os.path.exists(savedir):
        os.makedirs(savedir)
    req = urlopen(url)
    with open(dest, 'wb') as f:
        f.write(req.read())
    return dest
460085
def set(self, prefix, url, obj):
        
        if not self.cache_dir:
            return

        filename = self._get_cache_file(prefix, url)

        try:
            os.makedirs(os.path.join(self.cache_dir, prefix))
        except OSError:
            pass

        with open(filename, 'wb') as file:
            pickle.dump(obj, file)
822672
def _tool_to_dict(tool, records, remapped):
    
    requirements = _requirements_to_dict(tool.requirements + tool.hints)
    inputs = []
    outputs = []
    for inp in tool.tool["inputs"]:
        ready_inp, records = _input_to_dict(inp, records, remapped)
        inputs.append(ready_inp)
    for outp in tool.tool["outputs"]:
        ready_outp, records = _output_to_dict(outp, records)
        outputs.append(ready_outp)
    out = {"name": _id_to_name(tool.tool["id"]),
           "baseCommand": " ".join(tool.tool["baseCommand"]),
           "arguments": [_arg_to_dict(a, requirements) for a in tool.tool["arguments"]],
           "inputs": inputs,
           "outputs": outputs,
           "requirements": requirements,
           "stdin": None, "stdout": None}
    return out, records
20105
def distribute(self, cache):
        
        data = self._features_as_kv()
        for key in data.keys():
            cache.batch_set(data[key])
956196
def validate_and_handle(self, cli, buffer):
        
        if buffer.validate():
            if self.handler:
                self.handler(cli, buffer)

            buffer.append_to_history()
353927
def save_cache(data, filename):
    """"""
    with open(filename, 'wb') as handle:
        pickle.dump(data, handle)