Skip to content
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

build: restore configure formatting, add final message for warnings #623

Closed
wants to merge 0 commits into from

Conversation

silverwind
Copy link
Contributor

This is a follow-up on #483. It fixes the readability concern of #595 by restoring the options print to its previous pretty-printed form while adding a final print in case if warnings happened.

I also took the liberty to change the color of warnings from light red to light yellow, as I think that color is more appropriate and red should be reserved for errors only.

@silverwind silverwind changed the title build: Restore configure formatting, add final message for warnings build: restore configure formatting, add final message for warnings Jan 27, 2015
@rvagg
Copy link
Member

rvagg commented Jan 27, 2015

fine by me, can you give us a screenshot or fixed-format paste into here?

@silverwind
Copy link
Contributor Author

Here you go, had to reduce the font size a bit to fit everything on this tiny screen.

screenshot_26

@rvagg
Copy link
Member

rvagg commented Jan 27, 2015

lgtm but I'd like signoff from @bnoordhuis too cause I know he did some refactoring of #483 in #585 and may also have suggestions for wording (I don't really like "Careful! Warnings happened" but can't think of a good alternative).

@silverwind
Copy link
Contributor Author

I'm open to any suggestions regardind the print and its color. Also noticed I could refactor the final check by removing the msg variable, if that style is prefered.

prefix = '\033[1m\033[91mWARNING\033[0m' if os.isatty(1) else 'WARNING'
global warned
warned = True
prefix = '\033[1m\033[93mWARNING\033[0m' if os.isatty(1) else 'WARNING'
print('%s: %s' % (prefix, msg))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's slightly more pythonic to replace the global with:

def warn(msg):
  # ...
  warn.warned = True
warn.warned = False

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I'll fix that.

@silverwind silverwind force-pushed the configure-warnings branch 3 times, most recently from 857a4b4 to d2723a2 Compare January 28, 2015 16:36
@silverwind
Copy link
Contributor Author

@bnoordhuis updated with your suggestions.

@silverwind
Copy link
Contributor Author

@bnoordhuis wait, I'll push another update as I noticed this when no warnings occured:

AttributeError: 'function' object has no attribute 'warned'

@@ -297,7 +296,8 @@ auto_downloads = nodedownload.parse(options.download_list)


def warn(msg):
prefix = '\033[1m\033[91mWARNING\033[0m' if os.isatty(1) else 'WARNING'
warn.warned = True
prefix = '\033[1m\033[93mWARNING\033[0m' if os.isatty(1) else 'WARNING'
print('%s: %s' % (prefix, msg))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to define warn.warned, else you get an AttributeError below when warn() hasn't been called.

On the topic of the commit log, can you make the first line fit in <= 50 characters? Thanks!

@silverwind
Copy link
Contributor Author

Whoops, looks like I've broken this PR. Won't let me re-open it while the branch is still active. Guess I need to open a new one, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants