Skip to content

Commit

Permalink
QGIS plugin: Update GRASS version check for new QGIS version (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
landam committed Sep 1, 2024
1 parent c6b8f17 commit 0faa7be
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bin/qgis/smoderp2d-plugin/scripts/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ source $VENV/bin/activate

script_dir=$(realpath $(dirname $0))
echo $script_dir
### install released SMODERP2D version
pip3 install smoderp2d
### or from git
# (cd ../../.. ;pip3 install .)

pv=$(python3 -V | cut -d' ' -f 2 | cut -d'.' -f 1,2)
LIB=$VENV/lib/python$pv/site-packages
Expand Down
3 changes: 2 additions & 1 deletion bin/qgis/smoderp2d-plugin/smoderp_2D_dockwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def run(self):
for line in islice(fin, 1, 2):
if 'SMODERP2D patch applied' not in line:
raise ImportError(
'Your GRASS GIS installation needs to be fixed. Check the '
'There is a bug affecting the plugin functionality. Update QGIS to '
'version 3.34.10/3.38.2 or higher, or apply the fix manually. Check the '
'<a href="https://storm-fsv-cvut.github.io/smoderp2d-manual/providers.html#known-issue">documentation</a>.'
)
self.runner.create_location(QgsProject.instance().crs().authid())
Expand Down
2 changes: 2 additions & 0 deletions smoderp2d/providers/grass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def __init__(self, log_handler=GrassGisLogHandler):
os.environ['GRASS_OVERWRITE'] = '1'
# be quiet
os.environ['GRASS_VERBOSE'] = '0'
# allow to run r.hydrodem also when compatibility test fails
os.environ['GRASS_COMPATIBILITY_TEST'] = '0'

# define storage writer
self.storage = GrassGisWriter()
Expand Down
10 changes: 10 additions & 0 deletions smoderp2d/providers/grass/data_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,19 @@ def __init__(self, options, writer):
super(PrepareData, self).__init__(writer)

# install r.hydrodem if not available
install_ext = False
ext = Module('g.extension', flags='a', stdout_=PIPE)
list_ext = ext.outputs.stdout.splitlines()
if 'r.hydrodem' not in list_ext:
install_ext = True
else:
# try to run the module
try:
Module("r.hydrodem", run_=False)
except Exception:
install_ext = True
if install_ext:
Logger.info("Installing r.hydrodem extension...")
Module('g.extension', extension='r.hydrodem')

def __del__(self):
Expand Down

0 comments on commit 0faa7be

Please sign in to comment.