Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion jube2/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,15 @@ def convert_type(value_type, value, stop=True):
def script_evaluation(cmd, script_type):
"""cmd will be evaluated with given script language"""
if script_type == "python":
return str(eval(cmd))
if "return " not in cmd:
try:
return str(eval(cmd))
except:
pass
loc = {}
i = cmd.rfind("return ")
exec(cmd[:i] + cmd[i:].replace("return ", "return_value = "), globals(), loc)
return str(loc["return_value"])
elif script_type in ["perl", "shell"]:
if script_type == "perl":
cmd = "perl -e \"print " + cmd + "\""
Expand Down