Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing][grass] Highlight GRASS error messages and warnings in log
And catch segmentation faults from GRASS commands and show a nice
helper text advising user that QGIS isn't at fault here ;)

Also add a tip to try disabling the v.external option if that setting
is enabled and a GRASS segfault occurs
  • Loading branch information
nyalldawson committed Nov 1, 2018
1 parent 484895e commit 676238b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions python/plugins/processing/algs/grass7/Grass7Utils.py
Expand Up @@ -379,7 +379,16 @@ def executeGrass(commands, feedback, outputCommands=None):
if 'r.out' in line or 'v.out' in line:
grassOutDone = True
loglines.append(line)
feedback.pushConsoleInfo(line)
if any([l in line for l in ['WARNING', 'ERROR']]):
feedback.reportError(line.strip())
elif 'Segmentation fault' in line:
feedback.reportError(line.strip())
feedback.reportError('\n' + Grass7Utils.tr('GRASS command crashed :( Try a different set of input parameters and consult the GRASS algorithm manual for more information.') + '\n')
if ProcessingConfig.getSetting(Grass7Utils.GRASS_USE_VEXTERNAL):
feedback.reportError(Grass7Utils.tr(
'Suggest disabling the experimental "use v.external" option from the Processing GRASS Provider options.') + '\n')
elif line.strip():
feedback.pushConsoleInfo(line.strip())

# Some GRASS scripts, like r.mapcalculator or r.fillnulls, call
# other GRASS scripts during execution. This may override any
Expand All @@ -405,9 +414,12 @@ def executeGrass(commands, feedback, outputCommands=None):
line[len('GRASS_INFO_PERCENT') + 2:]))
except:
pass
else:
loglines.append(line)
feedback.pushConsoleInfo(line)
if any([l in line for l in ['WARNING', 'ERROR']]):
loglines.append(line.strip())
feedback.reportError(line.strip())
elif line.strip():
loglines.append(line.strip())
feedback.pushConsoleInfo(line.strip())

if ProcessingConfig.getSetting(Grass7Utils.GRASS_LOG_CONSOLE):
QgsMessageLog.logMessage('\n'.join(loglines), 'Processing', Qgis.Info)
Expand Down

0 comments on commit 676238b

Please sign in to comment.