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

g.extension: show fatal message if installed Add-On doesn't exists in the repository #2916

Conversation

tmszi
Copy link
Member

@tmszi tmszi commented Apr 14, 2023

Describe the bug
If you try install install non exists Add-On, g.extension module fail.

To Reproduce
Steps to reproduce the behavior:

  1. Try install some non exists Add-On g.extension non_exists_addon
  2. See error
GRASS world_latlong_wgs84/PERMANENT:~ > g.extension non_exists_addon
Fetching <non_exists_addon> from <https://github.com/OSGeo/grass-addons>
(be patient)...
Traceback (most recent call last):
  File "/usr/lib64/grass83/scripts/g.extension", line 2867, in <module>
    sys.exit(main())
  File "/usr/lib64/grass83/scripts/g.extension", line 2847, in main
    install_extension(source=source, url=url, xmlurl=xmlurl, branch=branch)
  File "/usr/lib64/grass83/scripts/g.extension", line 1230, in install_extension
    ) = install_extension_std_platforms(
  File "/usr/lib64/grass83/scripts/g.extension", line 1991, in install_extension_std_platforms
    srcdir = download_source_code(
  File "/usr/lib64/grass83/scripts/g.extension", line 1903, in download_source_code
    directory = download_source_code_official_github(
  File "/usr/lib64/grass83/scripts/g.extension", line 1779, in download_source_code_official_github
    ga.fetch_addons([name])
  File "/usr/lib64/grass83/scripts/g.extension", line 411, in fetch_addons
    *[self.addons[addon] for addon in addon_list],
  File "/usr/lib64/grass83/scripts/g.extension", line 411, in <listcomp>
    *[self.addons[addon] for addon in addon_list],
KeyError: 'non_exists_addon'

Expected behavior
Fatal message should be printed.

GRASS world_latlong_wgs84/PERMANENT:~ > g.extension non_exists_addon
Fetching <non_exists_addon> from <https://github.com/OSGeo/grass-addons>
(be patient)...
ERROR: Add-On name <non_exists_addon> doesn't exists in the repository. Try
       it again with correct Add-On name, please.

System description (please complete the following information):

  • Operating System: all
  • GRASS GIS version: 8.3.dev

@tmszi tmszi added the bug Something isn't working label Apr 14, 2023
Copy link
Member

@ninsbl ninsbl left a comment

Choose a reason for hiding this comment

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

Good catch. ANd thanks for the quick fix, @tmszi !
The code looks good to me. One could discuss if this should be an error or a warning message (when the attempts to download and compile are skipped). But for now, fatal seems right.

The suggested changes are just that, suggestions. So feel free to ignore.

scripts/g.extension/g.extension.py Outdated Show resolved Hide resolved
scripts/g.extension/g.extension.py Outdated Show resolved Hide resolved
@ninsbl
Copy link
Member

ninsbl commented Apr 14, 2023

BTW, you may add a test case for this issue to the download test!

@tmszi
Copy link
Member Author

tmszi commented Apr 14, 2023

BTW, you may add a test case for this issue to the download test!

Yes, you are right, I added it.

@tmszi tmszi merged commit 49f5cad into OSGeo:main Apr 14, 2023
@tmszi tmszi deleted the g_extension_fix_show_fatal_message_if_addon_does_not_exists branch April 14, 2023 18:55
@nilason nilason added backport_needed Python Related code is in Python labels Apr 15, 2023
@nilason nilason added this to the 8.3.0 milestone Apr 15, 2023
@nilason
Copy link
Contributor

nilason commented Apr 15, 2023

To be backported with #2895

neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants