Add debug for failing gdal subprocess

This commit is contained in:
Matthias Kuhn 2016-04-17 17:01:45 +02:00
parent de0e36703f
commit 151204dee0
2 changed files with 12 additions and 10 deletions

View File

@ -69,7 +69,7 @@ class GdalUtils:
loglines = []
loglines.append('GDAL execution console output')
fused_command = ''.join(['%s ' % c for c in commands])
fused_command = ' '.join([unicode(c) for c in commands])
progress.setInfo('GDAL command:')
progress.setCommand(fused_command)
proc = subprocess.Popen(
@ -81,9 +81,12 @@ class GdalUtils:
universal_newlines=True,
).stdout
progress.setInfo('GDAL command output:')
for line in iter(proc.readline, ''):
progress.setConsoleInfo(line)
loglines.append(line)
try:
for line in proc:
progress.setConsoleInfo(line)
loglines.append(line)
except IOError as e:
raise IOError(e.message + u'\nAfter reading {} lines, last lines: {}'.format(len(logines), u'\n'.join(loglines[-10:])))
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
GdalUtils.consoleOutput = loglines

View File

@ -68,9 +68,8 @@ class OgrInfo(GdalAlgorithm):
def processAlgorithm(self, progress):
GdalUtils.runGdal(self.getConsoleCommands(), progress)
output = self.getOutputValue(self.OUTPUT)
f = open(output, 'w')
f.write('<pre>')
for s in GdalUtils.getConsoleOutput()[1:]:
f.write(unicode(s))
f.write('</pre>')
f.close()
with open(output, 'w') as f:
f.write('<pre>')
for s in GdalUtils.getConsoleOutput()[1:]:
f.write(s)
f.write('</pre>')