From b2ba8e9c8593c31585ce552addc1d6ba85d06437 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Sun, 30 Nov 2014 12:35:08 +0200 Subject: [PATCH] [processing] fix GRASS output parser (fix #10660) --- .../algs/grass/ext/HtmlReportPostProcessor.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/python/plugins/processing/algs/grass/ext/HtmlReportPostProcessor.py b/python/plugins/processing/algs/grass/ext/HtmlReportPostProcessor.py index 2d1d72cad79..e3f565b39f0 100644 --- a/python/plugins/processing/algs/grass/ext/HtmlReportPostProcessor.py +++ b/python/plugins/processing/algs/grass/ext/HtmlReportPostProcessor.py @@ -25,16 +25,15 @@ __copyright__ = '(C) 2012, Victor Olaya' __revision__ = '$Format:%H$' +import codecs def postProcessResults(alg): htmlFile = alg.getOutputFromName('html').value grassName = alg.grassName - found = False - f = open(htmlFile, 'w') - f.write('

' + grassName + '

\n') - for line in alg.consoleOutput: - if found and not line.strip().endswith('exit'): - f.write(line + '
\n') - if grassName in line and not line.startswith('GRASS'): - found = True - f.close() + with codecs.open(htmlFile, 'w') as f: + f.write('

{}

\n'.format(grassName)) + f.write('
\n')
+        for line in alg.consoleOutput:
+            if not line.startswith('GRASS') and not line.isspace():
+                f.write('{}\n'.format(line))
+        f.write('
\n')