コード例 #1
0
ファイル: Form1.cs プロジェクト: kalaharileeu/PylauncherFSI
 /*Recursive function below:
 This is the entry point, main recursive loop tests*/
 /*this is a recursive, asynchrounous funstion function method runs asynchronously
 until all the tests in listbox 2 is done*/
 private async void runmainprocess()
 {
     //if the listbox2 is not empty it will keep running
     //launching processes
     if(listBox2.Items.Count != 0)
     {
         //find the first test in the list
         string testtorun = (string)(listBox2.Items[0]);
         //test used for url to report test
         test = testtorun;
         test = Regex.Replace(test, @"\s+", "%20");
         status = "Running";
         //Add the item that is running now to listbox3
         listBox3.Items.Add(testtorun);
         //remove it from listbox 2
         listBox2.Items.RemoveAt(0);
         //**********get all the task parameters here*********************
         Parameter.Test thetest = new Parameter.Test();
         thetest = tests.tests.Find(x => x.id.Equals(testtorun));
         if (thetest != null)
         {
             string parametertext = "";
             foreach (string s in thetest.Parsstring)
             {
                 if (s.Contains("SERIAL_NUMBER"))
                     parametertext += (" " + 
                         (string)textBox1.Text.Substring(textBox1.Text.Length - 12));
                 else
                     parametertext += (" " + s);//builds the command line string
             }
             textBox4.Clear();
             textBox4.Text = thetest.arguments + parametertext;
         }
         //************END of finding the task parameters*****************
         //A task gets kickef off here
         string t = await Task.Run(() => Runtest(testtorun));
         if (t.Contains("done"))
         {
             status = "Complete";
             shortreport();//Force a quick report of complete
             listBox3.Items.Clear();
             listBox4.Items.Add(testtorun);
         }
         //recursive call
         runmainprocess();
     }
 }
コード例 #2
0
        //private int totaltime;

        public void Load(Parameter.Test testparameters, string serialno = "")
        {
            this.testparameters = testparameters;
            /*Get all the paramters to run the test
            and  add then to a long string*/
            if (testparameters != null)
            {
                string parsaruments = "";
                foreach (string s in testparameters.Parsstring)
                {
                    if (s.Contains("SERIAL_NUMBER"))
                        parsaruments += (" " + serialno);
                    else
                        parsaruments += (" " + s);
                }
                //add the path of the .py file to the parsedarguments
                string commandarguments = testparameters.arguments + parsaruments;
                //After loading parameters run it
                Runtest(commandarguments, testparameters.filename, testparameters.workingdirectory);
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: kalaharileeu/ProcessLauncher
        public string Runtest(string itemtorun)
        {
            Parameter.Test Testtime = new Parameter.Test();
            Testtime = tests.tests.Find(x => x.id.Equals(itemtorun));
            if (Testtime != null)
            {
                string junk = "";
                foreach(string s in Testtime.Parsstring)
                {
                    if (s.Contains("SERIAL_NUMBER"))
                        junk += ( " " + (string)textBox1.Text.Substring(textBox1.Text.Length - 12));
                    else
                        junk += (" " + s);
                    //Console.WriteLine(junk);
                }
                //p.StartInfo.Arguments += junk;
                string runcommandarguments = Testtime.arguments + junk;
                Console.WriteLine(runcommandarguments);
                Process p = new Process(); // create process (i.e., the python program
                
                p.StartInfo.FileName = Testtime.filename;
                p.StartInfo.Arguments = runcommandarguments;
                p.StartInfo.RedirectStandardOutput = false;//check command line output
                p.StartInfo.RedirectStandardError = false;//Have to check error
                //p.StartInfo.RedirectStandardInput = false;
                p.StartInfo.UseShellExecute = false; //we can read or not the output from stdout
                p.StartInfo.WorkingDirectory = Testtime.workingdirectory;
                p.Start();
                //string g = p.StandardError.ReadToEnd();
                //string t = p.StandardOutput.ReadToEnd();//Reads the standard input
                //Console.WriteLine(t);//prints it out
                ///Console.WriteLine(g);//prints it out
                p.WaitForExit();
                if (p.ExitCode != 0)
                {               
                }

                //if (p.HasExited)
                //    p.Close();

               // itemtorun = Testtime.filename + Testtime.arguments + Testtime.Parsstring[0] +
               //     Testtime.Parsstring[1] + Testtime.Parsstring[2] + Testtime.Parsstring[3] + Testtime.Parsstring[4];
              //  Console.WriteLine(itemtorun);
            }
            else
            {
                Console.WriteLine(" Did not find the test id from XML file/n");
                return "Could not find the test";
            }

            return "done: ";
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: kalaharileeu/PylauncherFSI
        //This function only gets called from asychronous functions.
        private string Runtest(string itemtorun)
        {
            //The next set of code searches out the code from the 
            //instantiated test paremeters
            Parameter.Test theparameters = new Parameter.Test();
            theparameters = tests.tests.Find(x => x.id.Equals(itemtorun));
            if (theparameters != null)
            {
                string parsaruments = "";
                foreach(string s in theparameters.Parsstring)
                {
                    if (s.Contains("SERIAL_NUMBER"))
                        parsaruments += ( " " + 
                            (string)textBox1.Text.Substring(textBox1.Text.Length - 12));
                    else
                        parsaruments += (" " + s);
                }
                string runcommandarguments = theparameters.arguments + parsaruments;

                testrunnernostop.Load(theparameters,
                    (string)textBox1.Text.Substring(textBox1.Text.Length - 12));
            }
            else
            {
                return "Could not find the test";
            }

            return "done from launcher: ";
        }