public string CallScript(string scriptname) { var script = db.ContentOfTypePythonScript(scriptname); var engine = Python.CreateEngine(); var ms = new MemoryStream(); var sw = new StreamWriter(ms); engine.Runtime.IO.SetOutput(ms, sw); engine.Runtime.IO.SetErrorOutput(ms, sw); var sc = engine.CreateScriptSourceFromString(script); var code = sc.Compile(); var scope = engine.CreateScope(); var pe = new PythonEvents(db.Host); scope.SetVariable("model", pe); var qf = new QueryFunctions(pe.db); scope.SetVariable("q", qf); code.Execute(scope); pe.db.SubmitChanges(); ms.Position = 0; var sr = new StreamReader(ms); var s = sr.ReadToEnd(); return(s); }
public string CallScript(string scriptname) { var script = db.ContentOfTypePythonScript(scriptname); return(ExecutePython(script, new PythonEvents(db.Host, dictionary))); }