Skip to content

Commit

Permalink
Add debug for failing gdal subprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 17, 2016
1 parent de0e367 commit 151204d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 7 additions & 4 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Expand Up @@ -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(
Expand All @@ -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

Expand Down
11 changes: 5 additions & 6 deletions python/plugins/processing/algs/gdal/ogrinfo.py
Expand Up @@ -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.