Files
dev/script/pytst.py
2018-01-19 10:56:53 +01:00

21 lines
877 B
Python
Executable File

"""
import sys
import json
script ='C:\\Users\\gobbo_a\\Dev\\pshell\\pshell\\home\\script\\np.py'
function = 'add'
jsonargs = '[[1, 2, 3, 4, 5], [3, 3, 3, 3, 3]]'
args =json.loads(jsonargs)
i = script.rfind('/')
if i<0: i = script.rfind('\\')
module = script[i+1:-3]
path = script[:i+1]
sys.path.insert(1,path)
cmd = 'from ' + module + ' import ' + function + ' as function'
print cmd
exec cmd
ret = function(*args)
jsonret = json.dumps(ret)
print jsonret
"""
import sys;import json;script = 'C:\\Users\\gobbo_a\\Dev\\pshell\\pshell\\home\\script\\np.py';function = 'add';jsonargs = '[[1, 2, 3, 4, 5], [3, 3, 3, 3, 3]]';args =json.loads(jsonargs);i = script.rfind('\\');module = script[i+1:-3];path = script[:i+1];sys.path.insert(1,path);cmd = 'from ' + module + ' import ' + function + ' as function';exec cmd;ret = function(*args);jsonret = json.dumps(ret);print jsonret;