Reputation: 2755
I'm using Python to build multiple VS solutions from a given directory using msbuild.exe. I only want specific output, but to save work, the best way to interpret the results is with the original ANSI encoding.
Example:
import os
output = os.popen("MSBuild VSTests.sln").read()
print output
This prints the output, but without color. Is there any way to preserve this?
Upvotes: 4
Views: 1967
Reputation: 34744
You can't, as far as I know. The color is a property of the console and not of the output text itself. It's not like in Linux where you get escape characters in the text that set the color and reading that out back to console preserves color.
Another side effect of this is that you can't have a separate color for STDOUT
and STDERR
as shown in this SO question:
Setting stdout/stderr text color in Windows
Upvotes: 3