Example #1
0
 public void InitializePythonEngine()
 {
     try
     {
         Thread.CurrentThread.CurrentCulture = clsGlobal.MyCulture;
         this.PythonEngineOutput = new ListBoxStream(ref this.pythonOutput);
         this.pythonOutput.SelectedIndex = this.pythonOutput.Items.Add("Initializing Python Engine...");
         EngineOptions engineOptions = new EngineOptions();
         engineOptions.ClrDebuggingEnabled = true;
         this.engine = new PythonEngine(engineOptions);
         this.engine.AddToPath(ConfigurationManager.AppSettings["InstalledDirectory"] + @"\PythonStdLib");
         this.engine.AddToPath(ConfigurationManager.AppSettings["InstalledDirectory"] + @"\scripts");
         this.engine.AddToPath(ConfigurationManager.AppSettings["InstalledDirectory"] + @"\scripts\core");
         this.engine.AddToPath(Environment.CurrentDirectory);
         this.engine.AddToPath(Path.GetDirectoryName(Application.ExecutablePath));
         this.engine.Import("Site");
         this.engine.Import("System");
         this.engine.Import("System.Diagnostics");
         this.engine.Import("sys");
         this.engine.Import("nt");
         this.engine.Import("os");
         this.engine.Import("shutil");
         this.engine.Import("ConfigParser");
         this.engine.Import("time");
         this.engine.Import("array");
         this.engine.Import("pdb");
         this.engine.Execute("from System import Array");
         this.engine.Import("clr");
         this.engine.Execute("clr.AddReference('System.Messaging')");
         this.engine.Execute("from System.Messaging import MessageQueue");
         this.engine.Execute("MessageQueue.EnableConnectionCache = False");
         this.engine.Import("clr");
         this.engine.Execute("clr.AddReferenceByPartialName('CommonClassLibrary')");
         this.engine.Execute("from CommonClassLibrary import *");
         this.engine.SetStandardOutput(this.PythonEngineOutput);
         this.engine.SetStandardError(this.PythonEngineOutput);
         this.pythonOutput.SelectedIndex = this.pythonOutput.Items.Add("Python Engine Running.");
         this.engine.Execute("import clr");
         this.engine.Execute("clr.AddReferenceByPartialName('SiRFLive')");
         this.engine.Execute("from SiRFLive import *");
         this.engine.Execute("print dir()");
         this.engine.Execute("nt.chdir(\"..\\scripts\")");
     }
     catch (Exception exception)
     {
         this.pythonOutput.SelectedIndex = this.pythonOutput.Items.Add("Python Engine Failed to Start Properly: " + exception.Message);
     }
 }
Example #2
0
 public void InitializePythonEngine()
 {
     try
     {
         Thread.CurrentThread.CurrentCulture = clsGlobal.MyCulture;
         this.PythonEngineOutput             = new ListBoxStream(ref this.pythonOutput);
         this.pythonOutput.SelectedIndex     = this.pythonOutput.Items.Add("Initializing Python Engine...");
         EngineOptions engineOptions = new EngineOptions();
         engineOptions.ClrDebuggingEnabled = true;
         this.engine = new PythonEngine(engineOptions);
         this.engine.AddToPath(ConfigurationManager.AppSettings["InstalledDirectory"] + @"\PythonStdLib");
         this.engine.AddToPath(ConfigurationManager.AppSettings["InstalledDirectory"] + @"\scripts");
         this.engine.AddToPath(ConfigurationManager.AppSettings["InstalledDirectory"] + @"\scripts\core");
         this.engine.AddToPath(Environment.CurrentDirectory);
         this.engine.AddToPath(Path.GetDirectoryName(Application.ExecutablePath));
         this.engine.Import("Site");
         this.engine.Import("System");
         this.engine.Import("System.Diagnostics");
         this.engine.Import("sys");
         this.engine.Import("nt");
         this.engine.Import("os");
         this.engine.Import("shutil");
         this.engine.Import("ConfigParser");
         this.engine.Import("time");
         this.engine.Import("array");
         this.engine.Import("pdb");
         this.engine.Execute("from System import Array");
         this.engine.Import("clr");
         this.engine.Execute("clr.AddReference('System.Messaging')");
         this.engine.Execute("from System.Messaging import MessageQueue");
         this.engine.Execute("MessageQueue.EnableConnectionCache = False");
         this.engine.Import("clr");
         this.engine.Execute("clr.AddReferenceByPartialName('CommonClassLibrary')");
         this.engine.Execute("from CommonClassLibrary import *");
         this.engine.SetStandardOutput(this.PythonEngineOutput);
         this.engine.SetStandardError(this.PythonEngineOutput);
         this.pythonOutput.SelectedIndex = this.pythonOutput.Items.Add("Python Engine Running.");
         this.engine.Execute("import clr");
         this.engine.Execute("clr.AddReferenceByPartialName('SiRFLive')");
         this.engine.Execute("from SiRFLive import *");
         this.engine.Execute("print dir()");
         this.engine.Execute("nt.chdir(\"..\\scripts\")");
     }
     catch (Exception exception)
     {
         this.pythonOutput.SelectedIndex = this.pythonOutput.Items.Add("Python Engine Failed to Start Properly: " + exception.Message);
     }
 }