Exemplo n.º 1
0
    def getCachedFilename(self, uri, name=None):
        """Returns the local cached filename of the given uri/file"""

        if name == None:
            name = self.default_name
        for baseurl in self.baseurls.get(name, []):
            if uri.startswith(baseurl):
                uri = uri[len(baseurl):]
                break
        if self.__isURI(uri):
            return os.path.join(self.__getExternalCachedir(name), uri)
        if self.__isLocalURI([
                uri,
        ]):
            return _uriToFilename(uri)
        return os.path.join(self.__getCachedir(name), self.__makeRel(uri))
Exemplo n.º 2
0
    def createRepo(self):
        """Create repodata metadata for self.source.

        Return 1 on success, 0 on failure.  Assumes self.source is a local file
        system path without schema prefix."""

        import gzip, libxml2
        log.info1("Pass 1: Parsing package headers for file requires.")
        self.__readDir(self.source, "")
        filename = functions._uriToFilename(self.source)
        datapath = os.path.join(filename, "repodata")
        if not os.path.isdir(datapath):
            try:
                os.makedirs(datapath)
            except OSError, e:
                log.error("%s: Couldn't create repodata: %s", filename, e)
                return 0
Exemplo n.º 3
0
    def createRepo(self):
        """Create repodata metadata for self.source.

        Return 1 on success, 0 on failure.  Assumes self.source is a local file
        system path without schema prefix."""

        import gzip, libxml2
        log.info1("Pass 1: Parsing package headers for file requires.")
        self.__readDir(self.source, "")
        filename = functions._uriToFilename(self.source)
        datapath = os.path.join(filename, "repodata")
        if not os.path.isdir(datapath):
            try:
                os.makedirs(datapath)
            except OSError, e:
                log.error("%s: Couldn't create repodata: %s", filename, e)
                return 0
Exemplo n.º 4
0
              size=-1,
              md5=0,
              async=False,
              name=None):
        """Cache the given uri/file. If the uri is a real uri then we cache it
        in our external cache, otherwise we use our baseurl and treat the
        parameter as a relative path to it."""

        if name == None:
            name = self.default_name
        if not copy_local:
            path = None
            if self.__isLocalURI([
                    uri,
            ]):
                path = _uriToFilename(uri)
            elif self.is_local[name] and not self.__isURI(uri):
                path = _uriToFilename(
                    os.path.join(self.getBaseURL(), self.__makeRel(uri)))
            if path:
                if os.path.exists(path):
                    return path
                return None
        destfile = self.getCachedFilename(uri, name)
        if not os.path.isdir(os.path.dirname(destfile)):
            try:
                os.makedirs(os.path.dirname(destfile))
            except OSError:
                pass

        if self.callbacks.has_key(name):