Esempio n. 1
0
        public static string RunScript(InputParameter InputVariables)
        {
            PythonSettings settings = ModuleSettingsAccessor <PythonSettings> .GetSettings();

            //var pypath = "C:\\Users\\Corey\\AppData\\Local\\Programs\\Python\\Python37-32\\";
            //var path = "C:\\Users\\Corey\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe";
            var     pypath  = settings.PythonScriptDirectory;
            var     path    = settings.PythonDirectory;
            Process process = new Process();

            process.StartInfo.FileName = "cmd.exe";
            List <string> newArgs = new List <string>();

            newArgs.Add(pypath + InputVariables.fileName);
            newArgs.AddRange(InputVariables.args);

            process.StartInfo.Arguments              = "/c" + path + " " + String.Join(" ", newArgs); // Note the /c command (*)
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.Start();
            //* Read the output (or the error)
            string output = process.StandardOutput.ReadToEnd();

            Console.WriteLine(output);
            if (output == "")

            {
                string err = process.StandardError.ReadToEnd();
                Console.WriteLine(err);
                process.WaitForExit();
                return(err);
            }
            process.WaitForExit();
            return(output);
        }
Esempio n. 2
0
 //        /// <summary>
 //        /// Конструктор
 //        /// </summary>
 //        public GprFileInfo(PythonSettings pythSettings, Dictionary<int, MarksManagerClass.TypeMark> marks, List<int> ascanLengths, short fileVrsn, List<string> ascansGps, List<string> ascansTime)
 //        {
 //            pythonSettings = pythSettings;
 //            MarksMgr = new MarksManagerClass(marks);
 //            AscanLengths = ascanLengths;
 //            fileVersion = fileVrsn;
 //            AscansGPS = ascansGps;
 //            AscansTime = ascansTime;
 //        }
 public IGprFileInfo Clear()
 {
     pythonSettings = new PythonSettings();
     MarksMgr = new MarksManagerClass();
     AscanLengths = new List<int>();
     AscansGPS = new List<string>();
     AscansTime = new List<string>();
     fileVersion = 3;
     return this;
 }