Skip to content

Commit e1055c4

Browse files
committed
[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)
1 parent daf4c05 commit e1055c4

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,16 @@ def executeGrass(commands, feedback, outputCommands=None):
379379
if 'r.out' in line or 'v.out' in line:
380380
grassOutDone = True
381381
loglines.append(line)
382-
feedback.pushConsoleInfo(line)
382+
if any([l in line for l in ['WARNING', 'ERROR']]):
383+
feedback.reportError(line.strip())
384+
elif 'Segmentation fault' in line:
385+
feedback.reportError(line.strip())
386+
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')
387+
if ProcessingConfig.getSetting(Grass7Utils.GRASS_USE_VEXTERNAL):
388+
feedback.reportError(Grass7Utils.tr(
389+
'Suggest disabling the experimental "use v.external" option from the Processing GRASS Provider options.') + '\n')
390+
elif line.strip():
391+
feedback.pushConsoleInfo(line.strip())
383392

384393
# Some GRASS scripts, like r.mapcalculator or r.fillnulls, call
385394
# other GRASS scripts during execution. This may override any
@@ -405,9 +414,12 @@ def executeGrass(commands, feedback, outputCommands=None):
405414
line[len('GRASS_INFO_PERCENT') + 2:]))
406415
except:
407416
pass
408-
else:
409-
loglines.append(line)
410-
feedback.pushConsoleInfo(line)
417+
if any([l in line for l in ['WARNING', 'ERROR']]):
418+
loglines.append(line.strip())
419+
feedback.reportError(line.strip())
420+
elif line.strip():
421+
loglines.append(line.strip())
422+
feedback.pushConsoleInfo(line.strip())
411423

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

0 commit comments

Comments
 (0)