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

Allow showing the commands output #174

Merged
merged 3 commits into from
Aug 20, 2019

Conversation

s0undt3ch
Copy link
Contributor

Refs #173

@s0undt3ch
Copy link
Contributor Author

This was the least intrusive approach but it means changing the only debug log call to info.
The alternative would be to introduce another log level.
Let me know if its preferred to go down that route.

@theacodes
Copy link
Collaborator

Hmm, I'm not sold on this approach. I don't like the idea of introducing a new flag (I'm very conservative about this).

What do you (and others) think about being able to just override the "silent" arg to install?

session.install("requests", silent=False)

@s0undt3ch
Copy link
Contributor Author

s0undt3ch commented Mar 22, 2019

Since nox is pytest inspired, have you though about allowing noxfiles to extend the available CLI flags?
I know, off topic, but then again, not so much.

@s0undt3ch
Copy link
Contributor Author

Also, to answer your question, with your suggestion you can either have it always on or off(the output).
I'm not interested on that output locally, but I am interested on that output in a CI context...

nox/command.py Outdated
@@ -124,6 +124,9 @@ def run(

raise CommandFailed("Returned code {}".format(return_code))

if output:
logger.debug(output)
Copy link
Collaborator

Choose a reason for hiding this comment

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

So the problem with using logger.debug is that the output will actually differ from the normal operation because the logger appends nox > to the begging of each log-line. I would prefer that this goes to stderr just like the block above that sais if silent: sys.stderr.write(output).

@theacodes
Copy link
Collaborator

Cool - this mostly looks good then, just one comment about using logging to output the content.

@s0undt3ch
Copy link
Contributor Author

If we don't use logging we'll need to pass down the verbose flag to where we want verbose to be respected.
That's a whole lot of additional changes...
An additional verbose log level without the prefix you mention?

@s0undt3ch
Copy link
Contributor Author

Do you want the verbose flag passed down?

@theacodes
Copy link
Collaborator

theacodes commented Mar 23, 2019 via email

@s0undt3ch
Copy link
Contributor Author

Ok. I'll go down that route.

@erinwild
Copy link

erinwild commented Apr 7, 2019

It's already possible to override the silent flag in session.install (see #157). If the desired outcome is conditional reporting particularly in a CI context, the function in the noxfile could potentially handle this via extra arguments.

For example, nox -s tests -- verbose when additional verbosity is desired:

@nox.session(python='3.7')
def tests(session):
    verbosity = True if 'verbose' in session.posargs else False
    session.install('numpy', silent=verbosity)

@s0undt3ch
Copy link
Contributor Author

True, but you won't get any output unless the command fails.
I'm after output even if the install command doesn't fail.

@erinwild
Copy link

erinwild commented Apr 8, 2019

I will verify it and update you but I’m fairly sure setting the silent flag means that it doesn’t have to fail for it to be printed. This is precisely what I was looking for when I submitted the PR.

It looks like there hasn’t been a release since then, so perhaps that’s all that needs to happen @theacodes

@s0undt3ch
Copy link
Contributor Author

@erinwild-rubikloud you stand correct, passing silent=False shows the pip install output.

@s0undt3ch s0undt3ch closed this Apr 11, 2019
@theacodes
Copy link
Collaborator

theacodes commented Apr 11, 2019 via email

@s0undt3ch
Copy link
Contributor Author

Sure, I'll get back to it once I get some spare time.

@s0undt3ch s0undt3ch reopened this Apr 11, 2019
@s0undt3ch s0undt3ch force-pushed the features/verbose branch 2 times, most recently from 510a0ff to 8bd28f1 Compare April 13, 2019 16:11
@s0undt3ch
Copy link
Contributor Author

Ready for another set of eyes

nox/__main__.py Outdated
@@ -216,6 +218,10 @@ def main():
"--report", help="Output a report of all sessions to the given filename."
)

secondary.add_argument(
"--verbose", help="Show verbose output.", action="store_true"

Choose a reason for hiding this comment

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

Might be useful to mention here that it overrides the silent option.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, please do expand on this. Something like "Shows the output of all commands run, regardless of the silent argument."

@theacodes
Copy link
Collaborator

This looks mostly good except for the one comment. Can you add documentation as well? (If not, I can amend the PR to do it.)

@s0undt3ch
Copy link
Contributor Author

Applied suggestions.

@theacodes theacodes self-assigned this May 22, 2019
@theacodes theacodes changed the title Allow showing the commands output [Do not merge] Allow showing the commands output May 22, 2019
@theacodes
Copy link
Collaborator

This LGTM, but I'm going to merge #187 and fix this up to use the new options pattern first. :)

It'll make it in before the next release.

@theacodes theacodes changed the title [Do not merge] Allow showing the commands output [Awaiting 187] Allow showing the commands output May 23, 2019
@theacodes theacodes changed the title [Awaiting 187] Allow showing the commands output Allow showing the commands output May 28, 2019
@theacodes
Copy link
Collaborator

Okay, @s0undt3ch. I've rebased this to work with the changes for #187.

I do have an open question though: How does this handle cases such as silent=True and where the command fails?

@s0undt3ch
Copy link
Contributor Author

@theacodes Nothing is logged but the error is printed to stderr.

Also, fixed conflict and rebased.

@s0undt3ch
Copy link
Contributor Author

Conflicts resolved again.

@theacodes theacodes merged commit aeec1fa into wntrblm:master Aug 20, 2019
@theacodes
Copy link
Collaborator

Thank you thank you!

@s0undt3ch
Copy link
Contributor Author

Thank You!

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

Successfully merging this pull request may close these issues.

None yet

3 participants