Exemplo n.º 1
0
def validateManifest(jobObj, confObj):
    errors = []
    console = Context.console

    manifests = []

    # detect manifest path(s) as cli arg, ...
    global_let = confObj.get("let")
    if "ARGS" in global_let and len(global_let["ARGS"]) == 1:
        manifests.append(Manifest(global_let["ARGS"][0]))
    else:
        # ... from base.json ...
        libs = jobObj.get("library")
        for lib in libs:
            manifests.append(Manifest(lib.manipath))

        # ... or default location.
        if not manifests:
            manifests.append(Manifest("Manifest.json"))

    for mnfst in manifests:
        errors = mnfst.validateAgainst(Manifest.schema_v1_0())

        if errors:
            console.warn("Errors found in " + mnfst.path)
            console.indent()
            for error in errors:
                console.warn(error["msg"] + " in '%s' (JSONPath)" %
                             __convertToJSONPath(error["path"]))
            console.outdent()
        else:
            console.log("%s validates successful against used JSON Schema." %
                        mnfst.path)
Exemplo n.º 2
0
    def _init_from_manifest(self, libconfig=None):

        if libconfig is None:
            libconfig = self._libconfig

        manipath = libconfig['manifest']

        # check contrib:// URI
        if manipath.startswith("contrib://"):
            newmanipath = self._download_contrib(manipath)
            if not newmanipath:
                raise RuntimeError(
                    "Unable to get contribution from internet: %s" % manipath)
            else:
                manipath = newmanipath

        self.manifest = context.config.absPath(os.path.normpath(manipath))
        manifest = Manifest(self.manifest)

        self.path = os.path.dirname(self.manifest)
        self.uri = libconfig.get("uri", None)
        self.encoding = manifest.encoding
        self.classPath = manifest.classpath
        self.classUri = manifest.classpath  # TODO: ???
        self.translationPath = manifest.translation
        self.resourcePath = manifest.resource
        self.namespace = manifest.namespace

        self.categories["classes"]["path"] = self.classPath
        self.categories["translations"]["path"] = self.translationPath
        self.categories["resources"]["path"] = self.resourcePath

        if not self.namespace:
            raise RuntimeError
        self._checkNamespace()
Exemplo n.º 3
0
    def _init_from_manifest(self):

        # check contrib:// URI
        if self.manipath.startswith("contrib://"):
            newmanipath = self._download_contrib(self.manipath)
            if not newmanipath:
                raise RuntimeError(
                    "Unable to get contribution from internet: %s" %
                    self.manipath)
            else:
                self.manipath = context.config.absPath(
                    os.path.normpath(newmanipath))

        manifest = Manifest(self.manipath)
        self.manifest = manifest

        self.path = os.path.dirname(self.manipath)
        self.encoding = manifest.encoding
        self.classPath = manifest.classpath
        self.classUri = manifest.classpath  # TODO: ???
        self.resourcePath = manifest.resource
        self.namespace = manifest.namespace

        self.assets["classes"]["path"] = self.classPath
        self.assets["translations"]["path"] = manifest.translation
        self.assets["resources"]["path"] = self.resourcePath

        if not self.namespace:
            raise RuntimeError
Exemplo n.º 4
0
def validateManifest(jobObj, confObj):
    errors = []
    console = Context.console

    manifests = []

    # detect manifest path(s) as cli arg, ...
    global_let = confObj.get("let")
    if "ARGS" in global_let and len(global_let["ARGS"]) == 1:
        manifests.append(Manifest(global_let["ARGS"][0]))
    else:
        # ... from base.json ...
        libs = jobObj.get("library")
        if libs:
            for lib in libs:
                manifests.append(Manifest(lib.manipath))

        # ... or default location.
        if not manifests:
            manifests.append(Manifest("Manifest.json"))

    for mnfst in manifests:
        errors = __validate(mnfst._manifest, Manifest.schema_v1_0())
        __printResults(console, errors, mnfst.path)
Exemplo n.º 5
0
    def _init_from_manifest(self):

        # check contrib:// URI
        if self.manipath.startswith("contrib://"):
            newmanipath = self._download_contrib(self.manipath)
            if not newmanipath:
                raise RuntimeError(
                    "Unable to get contribution from internet: %s" %
                    self.manipath)
            else:
                self.manipath = context.config.absPath(
                    os.path.normpath(newmanipath))

        manifest = Manifest(self.manipath)
        self.manifest = manifest

        self.path = os.path.dirname(self.manipath)
        self.encoding = manifest.encoding
        self.classPath = manifest.classpath
        self.classUri = manifest.classpath  # TODO: ???
        self.resourcePath = manifest.resource
        self.namespace = manifest.namespace

        self.assets["classes"]["path"] = self.classPath
        self.assets["translations"]["path"] = manifest.translation
        self.assets["resources"]["path"] = self.resourcePath

        if not self.namespace:
            raise RuntimeError

        # ensure translation dir
        #transPath = os.path.join(self.path, self.assets['translations']["path"])
        #if not os.path.isdir(transPath):
        #    os.makedirs(transPath)

        self._dependencies_path = os.path.join(
            self.path,
            os.path.dirname(
                self.classPath),  # this is to come to 'source/script'
            'script',
            'dependencies.json')
Exemplo n.º 6
0
    def _init_from_manifest(self, libconfig=None):

        if libconfig is None:
            libconfig = self._libconfig

        self.manipath = libconfig['manifest']

        # check contrib:// URI
        if self.manipath.startswith("contrib://"):
            newmanipath = self._download_contrib(self.manipath)
            if not newmanipath:
                raise RuntimeError(
                    "Unable to get contribution from internet: %s" %
                    self.manipath)
            else:
                self.manipath = newmanipath

        self.manipath = context.config.absPath(os.path.normpath(self.manipath))
        manifest = Manifest(self.manipath)
        self.manifest = manifest

        self.path = os.path.dirname(self.manipath)
        self.uri = libconfig.get("uri", None)
        self.encoding = manifest.encoding
        self.classPath = manifest.classpath
        self.classUri = manifest.classpath  # TODO: ???
        self.resourcePath = manifest.resource
        self.namespace = manifest.namespace

        self.assets["classes"]["path"] = self.classPath
        self.assets["translations"]["path"] = manifest.translation
        self.assets["resources"]["path"] = self.resourcePath

        if not self.namespace:
            raise RuntimeError

        # ensure translation dir
        transPath = os.path.join(self.path,
                                 self.assets['translations']["path"])
        if not os.path.isdir(transPath):
            os.makedirs(transPath)
Exemplo n.º 7
0
    def _init_from_manifest(self):

        # check contrib:// URI
        if self.manipath.startswith(("contrib://", "http://", "https://")):
            raise RuntimeError((
                "Contrib URIs (starting with 'contrib://', 'http://' or 'https://') are "
                "no longer supported. Find the download locations of those in the contrib "
                "catalog and download them manually. Then point to the 'Manifest.json' files with local filepaths."
            ))

        manifest = Manifest(self.manipath)
        self.manifest = manifest

        self.path = os.path.dirname(self.manipath)
        self.encoding = manifest.encoding
        self.classPath = manifest.classpath
        self.classUri = manifest.classpath  # TODO: ???
        self.resourcePath = manifest.resource
        self.namespace = manifest.namespace

        self.assets["classes"]["path"] = self.classPath
        self.assets["translations"]["path"] = manifest.translation
        self.assets["resources"]["path"] = self.resourcePath

        if not self.namespace:
            raise RuntimeError

        # ensure translation dir
        #transPath = os.path.join(self.path, self.assets['translations']["path"])
        #if not os.path.isdir(transPath):
        #    os.makedirs(transPath)

        self._dependencies_path = os.path.join(
            self.path,
            os.path.dirname(
                self.classPath),  # this is to come to 'source/script'
            'script',
            'dependencies.json')
Exemplo n.º 8
0
    def resolveLibs(self, jobs):
        config = self.get("jobs")
        console = self._console

        console.info("Resolving libs/manifests...")
        console.indent()

        for job in jobs:
            if not self.getJob(job):
                raise RuntimeError, "No such job: \"%s\"" % job
            else:
                jobObj = self.getJob(job)
                console.debug("job '%s'" % jobObj.name)
                console.indent()
                if jobObj.hasFeature('library'):
                    newlib = []
                    seen = []
                    oldlib = jobObj.getFeature('library')
                    for lib in oldlib:
                        # handle downloads
                        manifest = lib['manifest']
                        manidir = os.path.dirname(manifest)
                        manifile = os.path.basename(manifest)

                        # wpbasti: Seems a bit crazy to handle this here
                        # What's about to process all "remote" manifest initially on file loading?
                        if manidir.startswith(
                                "contrib://"):  # it's a contrib:// lib
                            contrib = manidir.replace("contrib://", "")
                            cacheMap = jobObj.getFeature('cache')
                            if cacheMap and cacheMap.has_key('downloads'):
                                contribCachePath = cacheMap['downloads']
                                contribCachePath = self.absPath(
                                    contribCachePath)
                            else:
                                contribCachePath = "cache-downloads"
                            self._download_contrib(oldlib, contrib,
                                                   contribCachePath)
                            manifest = os.path.normpath(
                                os.path.join(contribCachePath, contrib,
                                             manifile))
                            lib['manifest'] = manifest  # patch 'manifest' entry to download path
                        else:  # patch the path which is local to the current config
                            pass  # TODO: use manidir and config._dirname, or fix it when including the config
                        lib['manifest'] = self.absPath(
                            lib['manifest'])  # abs manifest path

                        # get the local Manifest
                        manifest = Manifest(self.absPath(manifest))
                        lib = manifest.patchLibEntry(lib)
                        # absolutize paths (this might not be the best place to do that)
                        for entry in ('path', ):
                            lib[entry] = self.absPath(lib[entry])
                        # retain uri setting here
                        # add to newlib
                        if lib['namespace'] not in seen:  # enforce uniqueness
                            seen.append(lib['namespace'])
                            newlib.append(lib)
                            #TODO: newlib.append(Library(lib, self._console))
                        else:
                            self._console.debug(
                                "Skipping duplicate library \"%s\"" %
                                lib['namespace'])

                    jobObj.setFeature('library', newlib)

                console.outdent()

        console.outdent()