Skip to content
Permalink
Browse files

[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

(cherry picked from commit 676238b)
  • Loading branch information
nyalldawson committed Oct 31, 2018
1 parent daf4c05 commit e1055c4b7fbe729f6089540f3b8eca6765e51361
Showing with 16 additions and 4 deletions.
  1. +16 −4 python/plugins/processing/algs/grass7/Grass7Utils.py
@@ -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
@@ -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)

0 comments on commit e1055c4

Please sign in to comment.
You can’t perform that action at this time.