internal ExecutionSession(IExecutionEngineIO manager, Dictionary <string, object> Values, HashSet <AssemblyDeclaration> Assemblies) { CanExecute = true; Dictionary <string, object> args = new Dictionary <string, object>(); args["Debug"] = true; //IOManager IOManager = manager; // Create Engine Engine = IronPython.Hosting.Python.CreateEngine(args); // Create Scope Scope = InitializeScope(Values, Assemblies); // Redirect IO Engine.Runtime.IO.RedirectToConsole(); if (IOManager?.GetOutput() != null) { Console.SetOut(IOManager.GetOutput()); } if (IOManager?.GetError() != null) { Console.SetError(IOManager.GetError()); } if (IOManager?.GetInput() != null) { Console.SetIn(IOManager.GetInput()); } }
internal ExecutionSession(IExecutionEngineIO manager, Dictionary <string, object> Values, HashSet <AssemblyDeclaration> Assemblies) { CanExecute = true; //IOManager IOManager = manager; // Create Scope Scope = InitializeScope(Values, Assemblies); if (Scope == null) { CanExecute = false; return; } // Redirect IO using (Py.GIL()) { dynamic SYS = Scope.Import("sys"); SYS.stdout = new PythonOutput(); SYS.stderr = new PythonError(); SYS.stdin = new PythonInput(); } if (IOManager?.GetOutput() != null) { Console.SetOut(IOManager.GetOutput()); } if (IOManager?.GetError() != null) { Console.SetError(IOManager.GetError()); } if (IOManager?.GetInput() != null) { Console.SetIn(IOManager.GetInput()); } }