-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Feature/color on win #57
Feature/color on win #57
Conversation
Codecov Report
@@ Coverage Diff @@
## master #57 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 364 374 +10
Branches 56 57 +1
=========================================
+ Hits 364 374 +10
Continue to review full report at Codecov.
|
I don't quite get the coverage thing but will look into it. EDIT: I messed with settings and fixed them with a force push. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this.
Overall looks good (I'll have to assume most of this is okay since I don't have access to windows).
Two main things are:
- I prefer single quotes over double quotes
- I think we should enable tests for windows, even if we have to skip of xfail some tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great but unfortunately there are a number of conflicts.
If this is too annoying to fix, let me know and I'll fix as much of it as possible (I don't have windows so it'll involve a bit of guess work).
hi @Cielquan I'm afraid you still have lots of conflicts - see the PR summary above - that's what I meant by move into utils, not just rename. |
Year I rebased the up-to-date master into the branch .. but I need to fix some things .. the util.py was not there on the older master. |
Yes sorry about that, my fault. |
…to func; simplified utils._enable_vt_mode()
No problem. Thats normal to update I think it should now work. Lets see. |
yes, it's normal, but I try to always merge PRs in the order they were created so people don't have to fix conflicts caused by new PRs. However in this case, I was rushing to get some things fixed, thus merged newer PRs before this one. |
Oh we got a circular import problem with the merge of highlight.py into utils.py. I will refactor a bit to fix it. |
Ok I refactored I also moved tests into a new |
… to test_utils.py
@samuelcolvin The windows pipline fails because it cannot find |
So I fixed linux/mac with removal of The |
Sooooo .. finally done 🎆 The windows problem was |
@samuelcolvin Is it good to merge or do you need me to change something? 😺 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for the slow response, this looks great.
Just a few tiny comments and queries.
Co-authored-by: Samuel Colvin <[email protected]>
Co-authored-by: Samuel Colvin <[email protected]>
see above |
Thanks so much for this, sorry it took so long to merge. I'll make a new release soon. |
When do you think you can release the new version? 😃 |
sorry 🙏, been busy 🏃 . Just need to fix #62, then I can release. Will try to do so today. |
done, sorry for the delay. |
No problem. Thanks a lot 😄 |
Problem:
The problem is the missing support for colors on windows machines and is described in #55.
Changes:
devtools.debug.Debug._env_bool
classmethod as a functionenv_bool
indevtools.prettier
Reason: The method was not necessary to be a classmethod so I refactored it near
env_true
function which is used by the method.env_bool
.highlight
module which takes the roll to distinguish if highlighting is used. More info belowDebug.__init__
andDebug.__call__
for the use of the newhighlight.use_highlight
function.highlight
moduleOn import the module will, when on a windows machine, try to activate windows ANSI support by setting the
ENABLE_VIRTUAL_TERMINAL_PROCESSING
flag viaSetConsoleMode
. See here for more info: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences. Depending on the outcome thecolor_active
variable will be set.The code which does the work was posted here: https://bugs.python.org/msg291732. Truth be told I only kinda get what the code does but I think the author knows what he does. I tested it on two Win10 machines and it works.
Next there is the
use_highlight
function. It took over the work to distinguish ifDebugOutput.str
function called byDebug.__call__
should use highlighting. The function will first check if theDebug
class instance got created withhighlight=True
. If not set it will check thePY_DEVTOOLS_HIGHLIGHT
environment variable. If also not set it decides by checking ifisatty(file_)
andcolor_active
variable areTrue
. The latter part is new and the variable gets set on import (see above). The part before is just the old behavior.fixes #55
EDIT: Info: My added tests succeed on windows but 21 others do not.