Download, unzip, and parse the manifest from remote storage
766514
async function getOldManifest () {
  try {
    var data = await getFile('.manifest.json.gz')
  } catch (err) {
    if (err.code === 'NoSuchKey') return {}
    else throw err
  }
  var unzippedBody = zlib.gunzipSync(data.Body)
  return JSON.parse(unzippedBody)
}
637989
def download_extract(url):
    """"""
    logger.info("Downloading %s", url)
    request = urllib2.Request(url)
    request.add_header('User-Agent',
                       'caelum/0.1 +https://github.com/nrcharles/caelum')
    opener = urllib2.build_opener()
    with tempfile.TemporaryFile(suffix='.zip', dir=env.WEATHER_DATA_PATH) \
            as local_file:
        logger.debug('Saving to temporary file %s', local_file.name)
        local_file.write(opener.open(request).read())
        compressed_file = zipfile.ZipFile(local_file, 'r')
        logger.debug('Extracting %s', compressed_file)
        compressed_file.extractall(env.WEATHER_DATA_PATH)
        local_file.close()
1095091
def _getCleanupCommand(self):
        """"""
        return textwrap.dedent("""\
            set -v
            if [ -d .repo/manifests ]
            then
                # repo just refuse to run if manifest is messed up
                # so ensure we are in a known state
                cd .repo/manifests
                rm -f .git/index.lock
                git fetch origin
                git reset --hard remotes/origin/%(manifestBranch)s
                git config branch.default.merge %(manifestBranch)s
                cd ..
                ln -sf manifests/%(manifestFile)s manifest.xml
                cd ..
             fi
             repo forall -c rm -f .git/index.lock
             repo forall -c git clean -f -d -x 2>/dev/null
             repo forall -c git reset --hard HEAD 2>/dev/null
             rm -f %(workdir)s/.repo/project.list
             """) % dict(manifestBranch=self.manifestBranch,
                         manifestFile=self.manifestFile,
                         workdir=self.workdir)
312474
def fetch():
    
    mir, r, slackpkg_last_date = mirror(), "", ""
    count, upgraded = 0, []
    if mir:
        tar = urlopen(mir)
        try:
            r = tar.read()
        except AttributeError:
            print("sun: error: can't read mirror")
    if os.path.isfile(var_lib_slackpkg + changelog_txt):
        slackpkg_last_date = read_file("{0}{1}".format(
            var_lib_slackpkg, changelog_txt)).split("\n", 1)[0].strip()
    else:
        return [count, upgraded]
    for line in r.splitlines():
        if slackpkg_last_date == line.strip():
            break
        if (line.endswith("z:  Upgraded.") or line.endswith("z:  Rebuilt.") or
                line.endswith("z:  Added.") or line.endswith("z:  Removed.")):
            upgraded.append(line.split("/")[-1])
            count += 1
        if (line.endswith("*:  Upgraded.") or line.endswith("*:  Rebuilt.") or
                line.endswith("*:  Added.") or line.endswith("*:  Removed.")):
            upgraded.append(line)
            count += 1
    return [count, upgraded]
1043278
function createContentsZip(pluginDir, manifest) {
  return new Promise((res, rej) => {
    const output = new streamBuffers.WritableStreamBuffer();
    const zipFile = new ZipFile();
    let size = null;
    output.on("finish", () => {
      debug(`plugin.zip: ${size} bytes`);
      res(output.getContents());
    });
    zipFile.outputStream.pipe(output);
    sourceList(manifest).forEach(src => {
      zipFile.addFile(path.join(pluginDir, src), src);
    });
    zipFile.end(finalSize => {
      size = finalSize;
    });
  });
}
631551
public void downloadAndUnzip() {
        URL dataURL = null;
        String fileName = folder + "/" + url.substring(url.lastIndexOf("/") + 1);
        File compressedData = new File(fileName);
        if (!new File(fileName).exists()) {
            try {
                dataURL = new URL(url);
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            try {
                assert dataURL != null;
                FileUtils.copyURLToFile(dataURL, compressedData);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        try {
            ZipFile zipFile = new ZipFile(compressedData);
            File dataFolder = new File(folder);
            zipFile.extractAll(dataFolder.getCanonicalPath());
        } catch (ZipException | IOException e) {
            e.printStackTrace();
        }
    }
351954
def fetch_uri_contents(self, uri: str) -> URI:
        
        address, pkg_name, pkg_version = parse_registry_uri(uri)
        self.w3.enable_unstable_package_management_api()
        self.w3.pm.set_registry(address)
        _, _, manifest_uri = self.w3.pm.get_release_data(pkg_name, pkg_version)
        return manifest_uri
828260
def get_manifest(self, session, repository, ref):
        
        self.log.debug("%s: Retrieving manifest for %s:%s", session.registry, repository, ref)

        headers = {
            'Accept': ', '.join(self.manifest_media_types)
        }

        url = '/v2/{}/manifests/{}'.format(repository, ref)
        response = session.get(url, headers=headers)
        response.raise_for_status()
        return (response.content,
                response.headers['Docker-Content-Digest'],
                response.headers['Content-Type'],
                int(response.headers['Content-Length']))
507415
def parse_remote(cls, filename):
        """"""
        blob_file = cls._URL_FORMAT.search(filename)
        return cls._REMOTE_FILE("blob",
                                storage=blob_file.group("storage"),
                                container=blob_file.group("container"),
                                blob=blob_file.group("blob"))
225911
def read_local_manifest(self):
        

        manifest = file_or_default(self.get_full_file_path(self.manifest_file), {
            'format_version' : 2,
            'root'           : '/',
            'have_revision'  : 'root',
            'files'          : {}}, json.loads)

        if 'format_version' not in manifest or manifest['format_version'] < 2:
            raise SystemExit('Please update the client manifest format')
        return manifest
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)
36486
function downloadRepo(config, tmpFolder, callback) {

  console.log('Downloading repo...'.magenta);

  // Keep track if the request fails to prevent the continuation of the install
  var requestFailed = false;

  var repoUrl = 'http://server.webhook.com/';

  if(config.server) {
    if(config.server.indexOf('http://') !== 0) {
      config.server = config.server += 'http://';
    }

    if(config.server.indexOf(config.server.length - 1) !== '/') {
      config.server += '/';
    }

    repoUrl = config.server;
  }

  var repoRequest = request(repoUrl + 'download/?site=' + config.siteName + '&token=' + config.siteToken);

  repoRequest
    .on('response', function (response) {
      // If we fail, set it as failing and remove zip file
      if (response.statusCode !== 200) {
        requestFailed = true;
        fs.unlinkSync('repo.zip');
        callback(true);
      }
    })
    .pipe(fs.createWriteStream('repo.zip'))
    .on('close', function () {
      if (requestFailed) return;

      console.log('Extracting Files...'.magenta);
      // Unzip into temporary file
      var zip = new Zip('repo.zip');
      zip.extractAllTo(tmpFolder);
      fs.unlinkSync('repo.zip');
      callback(null, tmpFolder + '/' + fs.readdirSync(tmpFolder)[0]);
    });
}
203900
def install_from_zip(pkgpath, install_path, register_func, delete_after_install=False):
    """"""
    logger.debug("%s is a file, attempting to load zip", pkgpath)
    pkgtempdir = tempfile.mkdtemp(prefix="honeycomb_")
    try:
        with zipfile.ZipFile(pkgpath) as pkgzip:
            pkgzip.extractall(pkgtempdir)
    except zipfile.BadZipfile as exc:
        logger.debug(str(exc))
        raise click.ClickException(str(exc))
    if delete_after_install:
        logger.debug("deleting %s", pkgpath)
        os.remove(pkgpath)
    logger.debug("installing from unzipped folder %s", pkgtempdir)
    return install_dir(pkgtempdir, install_path, register_func, delete_after_install=True)
619814
function rezip(contentsZip) {
  return preprocessToRezip(contentsZip).then(
    ({ zipFile, entries, manifestJson, manifestPath }) => {
      validateManifest(entries, manifestJson, manifestPath);
      return rezipContents(zipFile, entries, manifestJson, manifestPath);
    }
  );
}
1257603
function parseManifest(manifest, docroot, callback)
{
  var inCache = false
    , lines = [];

    // get manifest file data
    fs.readFile(manifest, 'ascii', function(err, data)
    {
      var counter = 0;

      if (err)
      {
        // to prevent sudden continuation
        return callback(err);
      }

      cache[manifest] =
      {
        version: 0,
        files: [],
        manifest: data
      };

      lines = data.split('\n');

      lines.forEach(function(line)
      {
        var match;

        line = line.trim();

        // empty lines
        if (line.substr(0, 1) == '') return;

        // skip comments
        if (line.substr(0, 1) == '#') return;

        // process control keywords
        switch (line)
        {
          case 'CACHE MANIFEST':
          case 'CACHE:':
            inCache = true;
            return;
            break;

          // TODO: Add proper support for fallbacks
          case 'NETWORK:':
          case 'FALLBACK:':
            inCache = false;
            return;
            break;
        }

        // do nothing for network files
        if (!inCache) return;

        // check the file and setup monitoring
        if (!line.match(/^http(s)?:\/\//))
        {
          addWatcher(docroot+line, watcher(manifest), function(added, mtime)
          {
            // undo counter
            counter--;

            if (!added)
            {
              // check if everything is done
              if (counter == 0) callback();
              return;
            }

            if (mtime > cache[manifest].version) cache[manifest].version = mtime;

            cache[manifest].files.push(line);

            // check if everything is done
            if (counter == 0) callback();
          });

          // track inception
          counter++;
        }

      });
    });
}
901929
def download_from_files(files, output_path, width):
    """"""
    files_to_download = get_files_from_arguments(files, width)
    download_files_if_not_in_manifest(files_to_download, output_path)
1286584
def _load_manifest_interpret_source(manifest, source, username=None, password=None, verify_certificate=True, do_inherit=True):
    
    try:
        if isinstance(source, string_types):
            if source.startswith("http"):
                # if manifest is a url
                _load_manifest_from_url(manifest, source,
                                        verify_certificate=verify_certificate,
                                        username=username, password=password)
            else:
                _load_manifest_from_file(manifest, source)
            if not manifest.has_option('config', 'source'):
                manifest.set('config', 'source', str(source))
        else:
            # assume source is a file pointer
            manifest.readfp(source)
        if manifest.has_option('config', 'extends') and do_inherit:
            parent_manifest = configparser.RawConfigParser()
            _load_manifest_interpret_source(parent_manifest,
                                            manifest.get('config', 'extends'),
                                            username=username,
                                            password=password,
                                            verify_certificate=verify_certificate)
            for s in parent_manifest.sections():
                for k, v in parent_manifest.items(s):
                    if not manifest.has_option(s, k):
                        manifest.set(s, k, v)

    except configparser.Error:
        logger.debug("", exc_info=True)
        error_message = sys.exc_info()[1]
        raise ManifestException("Unable to parse manifest!: {0}".format(error_message))