Skip to content
Permalink
Browse files

Add debug for failing gdal subprocess

  • Loading branch information
m-kuhn committed Apr 17, 2016
1 parent de0e367 commit 151204dee07355f172dfac374148704feabd0ff0
Showing with 12 additions and 10 deletions.
  1. +7 −4 python/plugins/processing/algs/gdal/GdalUtils.py
  2. +5 −6 python/plugins/processing/algs/gdal/ogrinfo.py
@@ -69,7 +69,7 @@ def runGdal(commands, progress=None):

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 @@ def runGdal(commands, progress=None):
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

@@ -68,9 +68,8 @@ def getConsoleCommands(self):
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>')

0 comments on commit 151204d

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