-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Windows/CMD] Colored prompts not working with ANSI-Escape Sequences in CMD-Shell #21
Comments
This is a good suggestion. Initializing colorama in Please check whether the new commit works for you. |
Sorry, I still noticed an issue with the use of colorama here, that I now investigated! "colorama" always wraps both output streams (STDOUT, STDERR) or neither. See these issues of colorama, that I found: So there is also a problem with the exit code in this case. If I try to run something like this:
or simpler, as a test, something like this:
...then the console text stays colored (when using your hardcoded reset) or it gets reset to black (when using "Fore.RESET"). So I suggest reopening this issue, as "colorama" doesn't seem to do the job for this application/issue atm. |
Hmm, that's too bad. I'm not sure we actually need color support, so I simply removed the ANSI escape sequences altogether. If you have a more stable solution feel free to provide a PR for it! (I'd then also happily add cross-platform color support to all other CLI tools that I've written.) (I still hope there will be some day where Python stuff "just works" under Windows.) |
Well, Windows 10 will get the new Windows Terminal that suppots ANSI escape codes and is closer to a CLI for Linux. So I guess, it's just not worth the trouble supporting older OSes and shells. Also at colorama issues people like to have an option to switch off colors via an environment variable:
colorama also seems to have various issues on Windows 10:
|
Closing this for the time being, falling back to a normal logger. PRs to add support are welcome but I think this is a non-essential feature. |
I saw you're using raw ANSI escape sequences for coloring the tags in you "print_error", "print_warning" and "print_info" functions.
While most modern shells support them, CMD-Shell on Windows is still around and doesn't.
In Python the package colorama is an easy fix for that.
It wraps the std-outputs and translates escape sequences to Win32-API-Calls or drops them for redirects, if necessary.
It is cross-platfom, still maintained and simple to use.
Simplest solution is to import it and initialize it in "main()" via "colorama.init()".
The text was updated successfully, but these errors were encountered: