mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-08 00:06:51 -05:00
[Processing] Retry gdal commands if they are interrupted
This commit is contained in:
parent
7cb77d8cfd
commit
09a2f9b343
@ -67,11 +67,16 @@ class GdalUtils:
|
|||||||
envval += '{}{}'.format(os.pathsep, path)
|
envval += '{}{}'.format(os.pathsep, path)
|
||||||
os.putenv('PATH', envval)
|
os.putenv('PATH', envval)
|
||||||
|
|
||||||
loglines = []
|
|
||||||
loglines.append('GDAL execution console output')
|
|
||||||
fused_command = ' '.join([unicode(c) for c in commands])
|
fused_command = ' '.join([unicode(c) for c in commands])
|
||||||
progress.setInfo('GDAL command:')
|
progress.setInfo('GDAL command:')
|
||||||
progress.setCommand(fused_command)
|
progress.setCommand(fused_command)
|
||||||
|
progress.setInfo('GDAL command output:')
|
||||||
|
success = False
|
||||||
|
retry_count = 0
|
||||||
|
while success == False:
|
||||||
|
loglines = []
|
||||||
|
loglines.append('GDAL execution console output')
|
||||||
|
try:
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
fused_command,
|
fused_command,
|
||||||
shell=True,
|
shell=True,
|
||||||
@ -80,13 +85,16 @@ class GdalUtils:
|
|||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
).stdout
|
).stdout
|
||||||
progress.setInfo('GDAL command output:')
|
|
||||||
try:
|
|
||||||
for line in proc:
|
for line in proc:
|
||||||
progress.setConsoleInfo(line)
|
progress.setConsoleInfo(line)
|
||||||
loglines.append(line)
|
loglines.append(line)
|
||||||
|
success = True
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise IOError(e.message + u'\nAfter reading {} lines, last lines: {}'.format(len(loglines), u'\n'.join(loglines[-10:])))
|
if retry_count < 5:
|
||||||
|
retry_count += 1
|
||||||
|
else:
|
||||||
|
raise IOError(e.message + u'\nTried 5 times without success. Last iteration stopped after reading {} line(s).\nLast line(s):\n{}'.format(len(loglines), u'\n'.join(loglines[-10:])))
|
||||||
|
|
||||||
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
|
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
|
||||||
GdalUtils.consoleOutput = loglines
|
GdalUtils.consoleOutput = loglines
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user