Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[processing] Return log lines from GdalUtils.runGdal instead of storing
in a class member
The previous approach was NOT thread safe, and it's easy to avoid
- Loading branch information
|
@@ -97,8 +97,7 @@ def runGdal(commands, feedback=None): |
|
|
success = False |
|
|
retry_count = 0 |
|
|
while not success: |
|
|
loglines = [] |
|
|
loglines.append(GdalUtils.tr('GDAL execution console output')) |
|
|
loglines = [GdalUtils.tr('GDAL execution console output')] |
|
|
try: |
|
|
with subprocess.Popen( |
|
|
fused_command, |
|
@@ -121,11 +120,7 @@ def runGdal(commands, feedback=None): |
|
|
len(loglines), u'\n'.join(loglines[-10:]))) |
|
|
|
|
|
QgsMessageLog.logMessage('\n'.join(loglines), 'Processing', Qgis.Info) |
|
|
GdalUtils.consoleOutput = loglines |
|
|
|
|
|
@staticmethod |
|
|
def getConsoleOutput(): |
|
|
return GdalUtils.consoleOutput |
|
|
return loglines |
|
|
|
|
|
@staticmethod |
|
|
def getSupportedRasters(): |
|
|
|
@@ -115,11 +115,11 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True): |
|
|
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)] |
|
|
|
|
|
def processAlgorithm(self, parameters, context, feedback): |
|
|
GdalUtils.runGdal(self.getConsoleCommands(parameters, context, feedback), feedback) |
|
|
console_output = GdalUtils.runGdal(self.getConsoleCommands(parameters, context, feedback), feedback) |
|
|
output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) |
|
|
with open(output, 'w') as f: |
|
|
f.write('<pre>') |
|
|
for s in GdalUtils.getConsoleOutput()[1:]: |
|
|
for s in console_output[1:]: |
|
|
f.write(str(s)) |
|
|
f.write('</pre>') |
|
|
|
|
|
|
@@ -85,11 +85,11 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True): |
|
|
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)] |
|
|
|
|
|
def processAlgorithm(self, parameters, context, feedback): |
|
|
GdalUtils.runGdal(self.getConsoleCommands(parameters, context, feedback), feedback) |
|
|
console_output = GdalUtils.runGdal(self.getConsoleCommands(parameters, context, feedback), feedback) |
|
|
output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) |
|
|
with open(output, 'w') as f: |
|
|
f.write('<pre>') |
|
|
for s in GdalUtils.getConsoleOutput()[1:]: |
|
|
for s in console_output[1:]: |
|
|
f.write(str(s)) |
|
|
f.write('</pre>') |
|
|
|
|
|