Skip to content

Commit

Permalink
Merge pull request #3183 from DHI-GRAS/release-2_14
Browse files Browse the repository at this point in the history
[processing] fixes to GrassUtils and Grass7Utils (mostly cherry-picked jef-n)
  • Loading branch information
alexbruy committed Jun 24, 2016
2 parents a419515 + e94c24d commit 343e177
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 7 additions & 4 deletions python/plugins/processing/algs/grass/GrassUtils.py
Expand Up @@ -91,11 +91,14 @@ def grassPath():
folder = None
if folder is None:
if isWindows():
testfolder = os.path.dirname(QgsApplication.prefixPath())
if "OSGEO4W_ROOT" in os.environ:
testfolder = os.path.join(unicode(os.environ['OSGEO4W_ROOT']), "apps")
else:
testfolder = unicode(QgsApplication.prefixPath())
testfolder = os.path.join(testfolder, 'grass')
if os.path.isdir(testfolder):
for subfolder in os.listdir(testfolder):
if subfolder.startswith('grass'):
if subfolder.startswith('grass-6'):
folder = os.path.join(testfolder, subfolder)
break
else:
Expand All @@ -110,10 +113,10 @@ def grassWinShell():
folder = ProcessingConfig.getSetting(GrassUtils.GRASS_WIN_SHELL) or ''
if not os.path.exists(folder):
folder = None
if folder is None:
if folder is None and GrassUtils.grassPath():
folder = os.path.dirname(unicode(QgsApplication.prefixPath()))
folder = os.path.join(folder, 'msys')
return folder
return folder or ''

@staticmethod
def grassDescriptionPath():
Expand Down
7 changes: 5 additions & 2 deletions python/plugins/processing/algs/grass7/Grass7Utils.py
Expand Up @@ -88,7 +88,10 @@ def grassPath():
folder = None
if folder is None:
if isWindows():
testfolder = os.path.dirname(unicode(QgsApplication.prefixPath()))
if "OSGEO4W_ROOT" in os.environ:
testfolder = os.path.join(unicode(os.environ['OSGEO4W_ROOT']), "apps")
else:
testfolder = unicode(QgsApplication.prefixPath())
testfolder = os.path.join(testfolder, 'grass')
if os.path.isdir(testfolder):
for subfolder in os.listdir(testfolder):
Expand All @@ -100,7 +103,7 @@ def grassPath():
if not os.path.isdir(folder):
folder = '/Applications/GRASS-7.0.app/Contents/MacOS'

return folder
return folder or ''

@staticmethod
def grassDescriptionPath():
Expand Down

0 comments on commit 343e177

Please sign in to comment.