8000 add -v cmdline flag to pyvisa-shell for warn/info/debug logging output by jllanfranchi · Pull Request #816 · pyvisa/pyvisa · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add -v cmdline flag to pyvisa-shell for warn/info/debug logging output #816

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

Merged
merged 5 commits into from
Sep 24, 2024

Conversation

jllanfranchi
Copy link
Contributor

This commit adds -v (or -vv or -vvv or -v -v or -v -v -v) as command line flags that can be passed to pyvisa-shell such that WARN (-v), INFO (-vv), or DEBUG (-vvv) messages will be emitted when running the shell. This can help users understand why a device is not listed that they believe should be listed when using that tool. Guidance in documentation can be added (by me, in the near future) to tell users to utilize these options if things are not working correctly. As it stands now, pyvisa-shell just doesn't say anything, and the only way to get increased messages is to write a Python script to do this.

This commit, along with pyvisa/pyvisa-py#423 in the pyvisa-py, (as soon as I also update documentation appropriately) will close #758 and I expect will also close #791.

Copy link
codecov bot commented Apr 8, 2024

Codecov Report

Attention: Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.

Project coverage is 79.55%. Comparing base (0285909) to head (3dcf0b8).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pyvisa/cmd_line_tools.py 14.28% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #816   +/-   ##
=======================================
  Coverage   79.55%   79.55%           
=======================================
  Files          27       27           
  Lines        5380     5380           
  Branches      515      515           
=======================================
  Hits         4280     4280           
  Misses       1073     1073           
  Partials       27       27           
Flag Coverage Δ
unittests 79.46% <14.28%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -43,6 +51,11 @@ def visa_main(command: Optional[str] = None) -> None:
subparsers.add_parser("shell", help="start the PyVISA console")

args = parser.parse_args()
logging.basicConfig(
level={0: logging.ERROR, 1: logging.WARN, 2: logging.INFO, 3: logging.DEBUG}[
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason for an int-indexed dict instead of a tuple/list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None at all! A tuple or list would be more compact, no less explicit, & works just as well.

Copy link
Member

Choose a reason for hiding this comment

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

Can you address this then ?

@arr-ee
Copy link
Contributor
arr-ee commented Apr 8, 2024

Good call on making logging easier to enable here.

I think that WARN might be a more useful default value since this is an interactive session — wdyt?

@jllanfranchi
Copy link
Contributor Author
jllanfranchi commented Apr 8, 2024

One issue with making WARN default is that it changes the current behavior. If we're willing to change the current behavior, then I'm fine with that (and would kinda prefer it, so users get useful advice without having to figure out there's a -v option in the first place).

Another consideration is whether we want to add a command line option that decreases the verbosity level back to ERROR (presumably the default now), if users don't want to see WARN-level messages at all? (Seems like WARN level messages shouldn't be too annoying, though...)

@arr-ee
Copy link
Contributor
arr-ee commented Apr 8, 2024

and would kinda prefer it, so users get useful advice without having to figure out there's a -v option in the first place

This is exactly why I think WARN should be the default, yes. I am not too bothered about change of behaviour — although I'd love to hear from folks using the shell if I'm wrong!

Another consideration is whether we want to add a command line option that decreases the verbosity level back to ERROR

This is fair, -q/--quiet?

Copy link
Member
@MatthieuDartiailh MatthieuDartiailh left a comment

Choose a reason for hiding this comment

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

I agree WARN is a sane default for such a case. We can -q but I do not see people needing it to be honest. If anybody is using the shell enough to be bothered by a warning they may be better served by a script.

@@ -43,6 +51,11 @@ def visa_main(command: Optional[str] = None) -> None:
subparsers.add_parser("shell", help="start the PyVISA console")

args = parser.parse_args()
logging.basicConfig(
level={0: logging.ERROR, 1: logging.WARN, 2: logging.INFO, 3: logging.DEBUG}[
Copy link
Member

Choose a reason for hiding this comment

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

Can you address this then ?

@MatthieuDartiailh
Copy link
Member

ping @jllanfranchi could you address the small change request and I will merge.

@MatthieuDartiailh
Copy link
Member

I took the liberty to rebase your PR and make the small changes we discussed. I will merge by the end of the week.

@MatthieuDartiailh MatthieuDartiailh merged commit 4af61c1 into pyvisa:main Sep 24, 2024
16 of 17 checks passed
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.

[COM] Communication issue with Keysight DSOX4104A oscilloscope using USB ThorLabs PM100USB not listed by pyvisa-shell
3 participants
0