import sys
import json

script = sys.argv[1]
function = sys.argv[2]
jsonargs = sys.argv[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"
exec cmd

ret = function(*args)
jsonret = json.dumps(ret)

print jsonret

