1

i have a little question. Is it possible to get the logging stream (logging module) from a python script in C# using Process and ProcessStartInfo ?

As example:

ProcessStartInfo start = new ProcessStartInfo();
        start.RedirectStandardOutput = true;
        start.RedirectStandardError = true;
        start.FileName = "runtime\\bin\\python\\python_mcp";
        start.Arguments = "runtime\\decompile.py %*";
        start.CreateNoWindow = true;
        start.UseShellExecute = false;

        bBuild = true;
        sStatus = "Decompiling...";

        Process proc = new Process();
        proc.StartInfo = start;

        this.Invoke((MethodInvoker)delegate { rtOut.Clear(); });
        OutputMsg("========== Decompiling Binaries ==========");

        this.Invoke((MethodInvoker)delegate { proc.Start(); });

        while (!proc.StandardOutput.EndOfStream)
        {
            OutputMsg(proc.StandardOutput.ReadLine());
        }

        this.Invoke((MethodInvoker)delegate { proc.WaitForExit(); });
        this.Invoke((MethodInvoker)delegate { proc.Close(); });

        OutputMsg("========== Finished decompiling ==========");
        bBuild = false;
        sStatus = sIdleMessage;

but proc.StandardOutput.ReadLine() does not get any output. The standart print() output from python is caught but not the logging one

I hope someone can help me.

3
  • I have seen this question which may help: stackoverflow.com/questions/13671733/… . If not, can you post the rest of the code where you are attempting to read from the stream? Commented Jan 1, 2015 at 3:27
  • i added the whole method i'm using, and like i wrote the standart output by print() in python is displayed Commented Jan 1, 2015 at 19:11
  • I finally read your question properly so sorry for the unrelated post before. If you can (and I assume not), you could add a logging handler for the console to the python code and catch that. Otherwise, I don't know of a way to intercept the logging output from System.Process. Commented Jan 2, 2015 at 22:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.