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

Improve experience/error message when having permissions issues #209

Open
miek opened this issue Jan 16, 2025 · 0 comments
Open

Improve experience/error message when having permissions issues #209

miek opened this issue Jan 16, 2025 · 0 comments

Comments

@miek
Copy link
Member

miek commented Jan 16, 2025

Right now, if there's a permissions issue then an exception gets thrown from pyusb when trying to access string descriptors:

$>cynthion info
Cynthion version: 0.1.7
Apollo version: 1.1.0
Python version: 3.11.2 (main, May  2 2024, 11:59:08) [GCC 12.2.0]

Found Apollo stub interface!
Traceback (most recent call last):
  File "/home/cynthion/venv/bin/cynthion", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/cynthion/venv/lib/python3.11/site-packages/cynthion/commands/cli.py", line 92, in main
    args.func(args)
  File "/home/cynthion/venv/lib/python3.11/site-packages/cynthion/commands/cynthion_info.py", line 19, in cynthion_info
    if ApolloDebugger.print_info(force_offline=args.force_offline, out=logging.info,
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cynthion/venv/lib/python3.11/site-packages/apollo_fpga/__init__.py", line 436, in print_info
    out(f"\tBitstream: {device.product} ({device.manufacturer})")
                        ^^^^^^^^^^^^^^
  File "/home/cynthion/venv/lib/python3.11/site-packages/usb/core.py", line 875, in product
    self._product = util.get_string(self, self.iProduct)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cynthion/venv/lib/python3.11/site-packages/usb/util.py", line 313, in get_string
    raise ValueError("The device has no langid"
ValueError: The device has no langid (permission issue, no string descriptors supported or device error)

It hints at a permissions issue, but it's not great.

We should either do an earlier test of permissions or try and catch this exception, and print something more friendly.

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

No branches or pull requests

1 participant