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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quiet output for 'inspect --raw' #5702

Merged
merged 9 commits into from Oct 15, 2019
Merged

Conversation

@jgsogo
Copy link
Member

@jgsogo jgsogo commented Sep 3, 2019

Changelog: Fix: Add quiet output for inspect --raw.
Docs: omit

close #5656

This PR adds a quiet attribute to the @api_method decorator. If it is set, the output object is substituted during the command run and shallows all the output. If an exception is raised, then the output is shown:

  • a failure after PR
    image

  • same failure before
    image

Some colors are lost 馃槥 . If this is important I can record the write commands and send them using the original Output in the except block. It should do the trick, but I would need a helper class, wdyt?

This PR adds only this feature to the conan inspect ... --raw command, IMO we should use it for other raw/pristine commands too (consider it for JSON output for Conan 2.0?).


There are two outputs not covered with this approach:

  • Output from migrations (also mentioned in #5456 ). I would leave it as it is, migration should be only run once, that output shouldn't be an issue.
  • Python2 deprecation notice: it can be moved inside so it will use the original or the substituted output... but moving it inside implies that it will be printed from the ConanAPI not from Command.
@jgsogo jgsogo requested a review from memsharded Sep 3, 2019
@jgsogo jgsogo marked this pull request as ready for review Sep 3, 2019
conans/client/conan_api.py Outdated Show resolved Hide resolved
conans/client/conan_api.py Outdated Show resolved Hide resolved
except Exception as exc:
msg = exception_message_safe(exc)
def wrapper(api, *args, **kwargs):
silence = kwargs.pop("silence", False)
Copy link
Member

@memsharded memsharded Sep 10, 2019

Choose a reason for hiding this comment

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

I think this doesn't belong here, but this belongs to the ConanApp. Everything that will be consumed from the api is there, so no need to change api.xxx objects

Copy link
Member Author

@jgsogo jgsogo Sep 11, 2019

Choose a reason for hiding this comment

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

Some functions are taking the self.user_io from the ConanAPI (they can be using the output contained there) and not the self.app.user_io.

If I fix that, nothing taken from the ConanAPI and everything from the ConanApp, then I don't need to modify the app.xxxx objects, I would only need to pass my output to the create_app function (or the quiet argument) and it would be able to use the app.config instead of the environment variable.

I think that those are changes worth making

conans/client/command.py Outdated Show resolved Hide resolved
conans/client/command.py Outdated Show resolved Hide resolved
conans/test/functional/command/silence_test.py Outdated Show resolved Hide resolved
@lasote lasote assigned jgsogo and unassigned memsharded Sep 11, 2019
@jgsogo jgsogo force-pushed the bug/5656-inspect-raw branch from 4a98092 to 4ff2473 Sep 11, 2019
@jgsogo jgsogo changed the title Silence extra output for 'inspect --raw' Quiet output for 'inspect --raw' Sep 11, 2019
@jgsogo jgsogo force-pushed the bug/5656-inspect-raw branch from 18375a7 to aa711c6 Sep 11, 2019
@lasote lasote added this to the 1.20 milestone Sep 25, 2019
@jgsogo jgsogo added this to In progress in Output levels, warnings and errors via automation Sep 27, 2019
Copy link
Member

@memsharded memsharded left a comment

good!

Output levels, warnings and errors automation moved this from In progress to Reviewer approved Oct 14, 2019
@memsharded memsharded assigned lasote and unassigned jgsogo and memsharded Oct 14, 2019
lasote
lasote approved these changes Oct 15, 2019
Copy link
Contributor

@lasote lasote left a comment

馃憤

@lasote lasote merged commit 93d044e into conan-io:develop Oct 15, 2019
2 checks passed
Output levels, warnings and errors automation moved this from Reviewer approved to Done Oct 15, 2019
@jgsogo jgsogo deleted the bug/5656-inspect-raw branch Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants