Пример #1
0
def callApi(func, *args, **kwargs):
    if not hasattr(PYLOAD.EXTERNAL, func) or func.startswith("_"):
        print "Invalid API call", func
        return HTTPError(404, json.dumps("Not Found"))

    result = getattr(PYLOAD, func)(*[literal_eval(x) for x in args],
                                   **dict((x, literal_eval(y)) for x, y in kwargs.iteritems()))

    # null is invalid json  response
    return json.dumps(result or True, cls=TBaseEncoder)
Пример #2
0
def callApi(func, *args, **kwargs):
    if not hasattr(PYLOAD.EXTERNAL, func) or func.startswith("_"):
        print "Invalid API call", func
        return HTTPError(404, json.dumps("Not Found"))

    result = getattr(PYLOAD, func)(*[literal_eval(x) for x in args],
                                   **dict((x, literal_eval(y)) for x, y in kwargs.iteritems()))

    # null is invalid json  response
    return json.dumps(result or True, cls=TBaseEncoder)
Пример #3
0
                        self.core.log.error(_("%s has a invalid pattern") % name)
                        pattern = r'^unmatchable$'
                        regexp = re.compile(pattern)

                    plugins[name]['pattern'] = pattern
                    plugins[name]['re'] = regexp

                # internals have no config
                if folder == "internal":
                    self.core.config.deleteConfig("internal")
                    continue

                config = self.CONFIG.findall(content)
                if config:
                    try:
                        config = literal_eval(config[0].strip().replace("\n", "").replace("\r", ""))
                        desc = self.DESC.findall(content)
                        desc = desc[0][1] if desc else ""

                        if type(config[0]) == tuple:
                            config = [list(x) for x in config]
                        else:
                            config = [list(config)]

                        if folder not in ("account", "internal") and not [True for item in config if item[0] == "activated"]:
                            config.insert(0, ["activated", "bool", "Activated", False if folder in ("addon", "hook") else True])

                        self.core.config.addPluginConfig("%s_%s" % (name, folder), config, desc)
                    except Exception:
                        self.core.log.error("Invalid config in %s: %s" % (name, config))
Пример #4
0
                        self.core.log.error(_("%s has a invalid pattern") % name)
                        pattern = r'^unmatchable$'
                        regexp = re.compile(pattern)

                    plugins[name]['pattern'] = pattern
                    plugins[name]['re'] = regexp

                # internals have no config
                if folder == "internal":
                    self.core.config.deleteConfig("internal")
                    continue

                config = self.CONFIG.findall(content)
                if config:
                    try:
                        config = literal_eval(config[0].strip().replace("\n", "").replace("\r", ""))
                        desc = self.DESC.findall(content)
                        desc = desc[0][1] if desc else ""

                        if type(config[0]) == tuple:
                            config = [list(x) for x in config]
                        else:
                            config = [list(config)]

                        if folder not in ("account", "internal") and not [True for item in config if item[0] == "activated"]:
                            config.insert(0, ["activated", "bool", "Activated", not folder in ("addon", "hook")])

                        self.core.config.addPluginConfig("%s_%s" % (name, folder), config, desc)
                    except Exception:
                        self.core.log.error("Invalid config in %s: %s" % (name, config))