Пример #1
0
        /*
         *      public void UpdateSource(object sender, EventArgs e)
         *      {
         *          ScintillaNET.Scintilla control = sender as ScintillaNET.Scintilla;
         *          Source = control.Text;
         *          this._complexity = Source.Split(System.Environment.NewLine.ToCharArray()).Length;
         *      }
         */

        protected override void DoAction()
        {
            IPythonEngine engine = GetCurrentCore().PythonEngine;

            //if (!engine.VariableExists(@"variables"))
            //{
            //    engine.SetVariable(@"variables", Variables);
            //}
            try
            {
                engine.Execute(Source);
            }
            catch (PythonException e)
            {
                throw new ActionException(e, this);
            }
        }
Пример #2
0
        private void OsModuleWorkaround()
        {
            IPythonEngine engine       = GetCurrentCore().PythonEngine;
            var           progFilesX68 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
            string        pythonLibDir = Path.Combine(progFilesX68, "ironpython 2.7", "lib");

            if (!Directory.Exists(pythonLibDir))
            {
                var activeForm = Form.ActiveForm ?? (Form)this.GetCurrentCore().Tag;
                pythonLibDir =
                    (string)activeForm.Invoke(new Func <string>(this.GetPythonLibDir));
                if (String.IsNullOrEmpty(pythonLibDir))
                {
                    throw new FatalActionException("Could not find Python Lib folder", this);
                }
            }
            engine.ImportModule("sys");
            engine.Execute(string.Format("sys.path.append('{0}')\n", pythonLibDir));
            engine.ImportModule("os");
        }