0

I have a batch file which calls .Net solution to build the project. On the dos console window, the warning and error will be in different color, green and red, looks nice. When the batch file called from Python, no color at all, all in a single color. Is it possible to get the same colorful result with python? my call to the batch file is like this:

p = subprocess.Popen('manualBuild.bat', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 
for line in p.stdout.readlines(): 
    print line, 
retval = p.wait()

thanks

2 Answers 2

3

Some programs test to see if they're actually connected to a console/terminal, and suppress attribute changes if they're not in order to make it easier to parse/process the output. I know that on *nix systems you can use unbuffer to fool the program, but I don't know if there's a Windows equivalent.

Sign up to request clarification or add additional context in comments.

Comments

0

If this were UNIX, I'd suggest you don't get the output in a variable but just let the program print it out (ie. don't pass stdout to subprocess). Maybe you can try that once?

Comments

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.