def callApi(func, *args, **kwargs): if not hasattr(PYLOAD.EXTERNAL, func) or func.startswith("_"): print "Invalid API call", func return bottle.HTTPError(404, json_dumps("Not Found")) result = getattr(PYLOAD, func)(*[SafeEval.const_eval(x) for x in args], **dict((x, SafeEval.const_eval(y)) for x, y in kwargs.iteritems())) # null is invalid json response return json_dumps(result or True, cls=TBaseEncoder)
def call_API(func, *args, **kwargs): if not hasattr(API.EXTERNAL, func) or func.startswith("_"): print "Invalid API call", func return bottle.HTTPError(404, json_dumps("Not Found")) result = getattr(API, func)(*[SafeEval.const_eval(x) for x in args], **dict((x, SafeEval.const_eval(y)) for x, y in kwargs.iteritems())) # null is invalid json response return json_dumps(result or True, cls=TBaseEncoder)
def callRPC(self, plugin, func, args, parse): if not args: args = () if parse: args = tuple([SafeEval.const_eval(x) for x in args]) plugin = self.pluginMap[plugin] f = getattr(plugin, func) return f(*args)
def test(expr): # indent = "\t\t\t\t\t" indent = '\t' try: print 'testing expr:', expr val = SafeEval.math_expr_eval(expr) print indent, '[ OK ]:', indent, val except ValueError, v: print indent, '[ ERROR ]:', indent, 'ValueError:', v
def test(expr): # indent = "\t\t\t\t\t" indent = '\t' try: print 'testing expr:', expr val = SafeEval.math_expr_eval(expr) print indent, '[ OK ]:', indent, val except ValueError, v: print indent, '[ ERROR ]:', indent, 'ValueError:', v
def test(expr): # indent = "\t\t\t\t\t" indent = '\t' try: print('testing expr:', expr) val = SafeEval.math_expr_eval(expr) print(indent, '[ OK ]:', indent, val) except ValueError as v: print(indent, '[ ERROR ]:', indent, 'ValueError:', v) except Exception as e: print(indent, '[ ERROR ]:', indent, 'Exception:', e)
_("%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 = SafeEval.const_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.pyload.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.pyload.config.delete_config("internal") continue config = self.CONFIG.findall(content) if config: try: config = SafeEval.const_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.pyload.config.add_plugin_config("%s_%s" % (name, folder), config, desc) except Exception: