grass icon indicating copy to clipboard operation
grass copied to clipboard

g.extension: better handle request exceptions for l flag

Open tmszi opened this issue 3 years ago • 0 comments
trafficstars

Describe the bug When you disable internet connection and try download list of available addons via g.extension -l module, g.extension will try download module.xml file for GRASS GIS 7.8 version (see URL address in error message), due wrong handled request exception on line 254, before try to dowlnoad this file.

https://github.com/OSGeo/grass/blob/f720e3eba5d1462ad0b37f2b020c15f05870b05d/scripts/g.extension/g.extension.py#L247-L256

To Reproduce Steps to reproduce the behavior:

  1. Disable your internet connection
  2. Launch g.extension -l
  3. See error (request exception is handed correctly here, but URL address is incorrect due another request exception before this (line 254) is wrong handled.
GRASS nc_basic_spm_grass7/PERMANENT:~ > g.extension -l
List of available extensions (modules):
ERROR: Download file from
       <https://grass.osgeo.org/addons/grass7/modules.xml> failed. Check
       your internet connection.

https://grass.osgeo.org/addons/grass7/modules.xml -> grass7

Same for:

ERROR: Download file from
       <https://api.github.com/repos/OSGeo/grass-addons/git/trees/grass7?recursive=1>,
       failed. Check internet connection.

https://api.github.com/repos/OSGeo/grass-addons/git/trees/grass7?recursive=1 -> grass7

Expected behavior Correctly handled exception if internet connection is not available inside get_version_branch() function.

Error message should be:

GRASS nc_basic_spm_grass7/PERMANENT:~ > g.extension -l
ERROR: You are not connected to the internet. Check your internet
       connection.
GRASS nc_basic_spm_grass7/PERMANENT:~ > g.extension sentinel
ERROR: You are not connected to the internet. Check your internet
       connection.

System description:

  • GRASS GIS version: main, realesebranch_7_8, realesebranch_8_0

tmszi avatar Feb 13 '22 09:02 tmszi