Example #1
0
        private void SendViaPython(string bytesToSend, string pythonFilename)
        {
            try
            {
                var stopWatch = new System.Diagnostics.Stopwatch();
                stopWatch.Start();
                //string incomingHexPacket = DOSPrompt.RunPythonFile("python_socket.py", "\"" + bytesToSend + "\"");
                string incomingHexPacket = DOSPrompt.RunPythonFile(pythonFilename, "\"" + bytesToSend + "\"");
                stopWatch.Stop();
                lblCommandExecutionTime.Text = "Send and Read Time:" + stopWatch.ElapsedMilliseconds.ToString() + " ms";

                if (incomingHexPacket.IndexOf("error") > -1)
                {
                    WriteMessage(incomingHexPacket);
                }
                else
                {
                    ShowBytesInTextBoxes(GetBytes(incomingHexPacket));
                }
            }
            catch (Exception exc)
            {
                WriteMessage(exc.ToString());
                SaveLog(exc.ToString());
            }
        }
Example #2
0
        public string RunPython(string args)
        {
            string pythonExePath = Ini.IniFile.GetValue("Python", "ExePath");

            if (System.IO.File.Exists(pythonExePath))
            {
                return(DOSPrompt.CMDAutomate(args, pythonExePath));
            }
            else
            {
                return("error: " + pythonExePath + " not correct.");
            }
        }
Example #3
0
        public static string RunPythonFile(string fileName, string args)
        {
            string pythonExePath = Ini.IniFile.GetValue("Python", "ExePath");

            if (System.IO.File.Exists(pythonExePath))
            {
                string pythonFilePath  = "\"" + System.Windows.Forms.Application.StartupPath + "\\PythonFiles\\" + fileName + "\" ";
                string pythonFilePath2 = System.Windows.Forms.Application.StartupPath + "\\PythonFiles\\" + fileName;
                if (System.IO.File.Exists(pythonFilePath2))
                {
                    return(DOSPrompt.CMDAutomate(pythonFilePath + args, pythonExePath));
                }
                else
                {
                    return("error : " + pythonExePath + " not found.");
                }
            }
            else
            {
                return("error : " + pythonExePath + " not found.");
            }
        }
Example #4
0
        private void shellControl1_CommandEntered(object sender, CommandEnteredEventArgs e)
        {
            if (!ProcessInternalCommand(e.Command))
            {
                if (rbDos.Checked)
                {
                    string s = DOSPrompt.CMDAutomate(e.Command);
                    shellControl1.WriteText(s);
                    txtLastOutput.Text = s;
                }

                if (rbASCII.Checked)
                {
                    byte[] r = Common.SendBytes(txtIP.Text, txtPort.Text, ASCIIEncoding.ASCII.GetBytes(e.Command));
                    shellControl1.WriteText(ASCIIEncoding.ASCII.GetString(r));
                }

                if (rbHEX.Checked)
                {
                    byte[] r = Common.SendBytes(txtIP.Text, txtPort.Text, Common.GetBytesFromHex(e.Command));
                    shellControl1.WriteText(ASCIIEncoding.ASCII.GetString(r));
                }
            }
        }