Skip to content

Commit 343e177

Browse files
authored
Merge pull request #3183 from DHI-GRAS/release-2_14
[processing] fixes to GrassUtils and Grass7Utils (mostly cherry-picked jef-n)
2 parents a419515 + e94c24d commit 343e177

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

python/plugins/processing/algs/grass/GrassUtils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ def grassPath():
9191
folder = None
9292
if folder is None:
9393
if isWindows():
94-
testfolder = os.path.dirname(QgsApplication.prefixPath())
94+
if "OSGEO4W_ROOT" in os.environ:
95+
testfolder = os.path.join(unicode(os.environ['OSGEO4W_ROOT']), "apps")
96+
else:
97+
testfolder = unicode(QgsApplication.prefixPath())
9598
testfolder = os.path.join(testfolder, 'grass')
9699
if os.path.isdir(testfolder):
97100
for subfolder in os.listdir(testfolder):
98-
if subfolder.startswith('grass'):
101+
if subfolder.startswith('grass-6'):
99102
folder = os.path.join(testfolder, subfolder)
100103
break
101104
else:
@@ -110,10 +113,10 @@ def grassWinShell():
110113
folder = ProcessingConfig.getSetting(GrassUtils.GRASS_WIN_SHELL) or ''
111114
if not os.path.exists(folder):
112115
folder = None
113-
if folder is None:
116+
if folder is None and GrassUtils.grassPath():
114117
folder = os.path.dirname(unicode(QgsApplication.prefixPath()))
115118
folder = os.path.join(folder, 'msys')
116-
return folder
119+
return folder or ''
117120

118121
@staticmethod
119122
def grassDescriptionPath():

python/plugins/processing/algs/grass7/Grass7Utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ def grassPath():
8888
folder = None
8989
if folder is None:
9090
if isWindows():
91-
testfolder = os.path.dirname(unicode(QgsApplication.prefixPath()))
91+
if "OSGEO4W_ROOT" in os.environ:
92+
testfolder = os.path.join(unicode(os.environ['OSGEO4W_ROOT']), "apps")
93+
else:
94+
testfolder = unicode(QgsApplication.prefixPath())
9295
testfolder = os.path.join(testfolder, 'grass')
9396
if os.path.isdir(testfolder):
9497
for subfolder in os.listdir(testfolder):
@@ -100,7 +103,7 @@ def grassPath():
100103
if not os.path.isdir(folder):
101104
folder = '/Applications/GRASS-7.0.app/Contents/MacOS'
102105

103-
return folder
106+
return folder or ''
104107

105108
@staticmethod
106109
def grassDescriptionPath():

0 commit comments

Comments
 (0)