Ejemplo n.º 1
0
        public void TestConsoleCallerPython()
        {
            var process = new Process();

            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardInput  = true;
            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.WorkingDirectory       = @"C:\";
            process.StartInfo.FileName  = Path.Combine(Environment.SystemDirectory, "cmd.exe");
            process.StartInfo.Arguments = @"/c ""C:\python27\python.exe -i""";
            using (ProcessLauncher launcher = new ProcessLauncher(this, process))
            {
                launcher.consoleOutlineEvent += this.onConsoleOutputDataReceived;
                launcher.consoleErrorEvent   += this.onConsoleErrortDataReceived;
                try
                {
                    launcher.Start();
                    launcher.SendInput("import sys;\n");
                    launcher.SendInput("print \"Test.\";\n");
                }
                finally
                {
                    launcher.SendInput("exit()");
                }
            }
        }