Skip to content

Commit

Permalink
GRASS: replace hardcoded path by shutil.which
Browse files Browse the repository at this point in the history
  • Loading branch information
landam committed May 30, 2024
1 parent b92d3aa commit ef182bf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion smoderp2d/runners/grass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import subprocess
import tempfile
import binascii
import shutil

from smoderp2d.runners.base import Runner
from smoderp2d.providers import Logger
Expand Down Expand Up @@ -37,6 +38,7 @@ def _find_grass_bin_path():
:todo: Avoid bat file calling.
"""
if sys.platform == 'win32':
# MS Windows
if 'QGIS_PREFIX_PATH' in os.environ:
bin_path = os.path.join(os.environ['QGIS_PREFIX_PATH'],
'..', '..', 'bin')
Expand All @@ -54,7 +56,8 @@ def _find_grass_bin_path():
if grass_bin_path is None:
raise ImportError("No GRASS executable found.")
else:
grass_bin_path = '/usr/bin/grass'
# expecting GNU/Linux
grass_bin_path = shutil.which("grass")

return grass_bin_path

Expand Down

0 comments on commit ef182bf

Please sign in to comment.