conductor-worker-python/pyexecplugins/Eval.py

23 lines
704 B
Python
Raw Permalink Normal View History

2020-10-14 18:06:28 +02:00
from pyexecplugins.pyexecplugins import PyExecPlugin
import logging;
2020-10-14 18:06:28 +02:00
class Plugin(PyExecPlugin):
name = "Eval"
taskdef = {
"name" : "pyeval",
"description" : "Execute arbitrary python code",
"inputKeys" : ["code"],
"outputKeys" : ["result"],
"ownerEmail" : "m.lettere@gmail.com"
}
2021-03-22 16:36:35 +01:00
def __init__(self, data=None, config=None):
super().__init__(data, config)
2020-10-14 18:06:28 +02:00
def execute(self):
code = self.data.get("code")
if code != None:
logging.getLogger("pyexec").info("Going to eval: %s | with data: %s", code, str(self.data))
2020-10-14 18:06:28 +02:00
ret = eval(code, { "data" : self.data})
return { "result" : ret }