Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Fix exception on completion of batch execution of
algorithm which has string or numeric outputs
  • Loading branch information
nyalldawson committed Apr 26, 2019
1 parent c0105bd commit 66eabdd
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions python/plugins/processing/gui/BatchAlgorithmDialog.py
Expand Up @@ -89,7 +89,7 @@ def runAlgorithm(self):
if not param.checkValueIsAcceptable(wrapper.parameterValue()): if not param.checkValueIsAcceptable(wrapper.parameterValue()):
self.messageBar().pushMessage("", self.tr('Wrong or missing parameter value: {0} (row {1})').format( self.messageBar().pushMessage("", self.tr('Wrong or missing parameter value: {0} (row {1})').format(
param.description(), row + 1), param.description(), row + 1),
level=Qgis.Warning, duration=5) level=Qgis.Warning, duration=5)
return return
col += 1 col += 1
count_visible_outputs = 0 count_visible_outputs = 0
Expand All @@ -112,7 +112,7 @@ def runAlgorithm(self):
else: else:
self.messageBar().pushMessage("", self.tr('Wrong or missing output value: {0} (row {1})').format( self.messageBar().pushMessage("", self.tr('Wrong or missing output value: {0} (row {1})').format(
out.description(), row + 1), out.description(), row + 1),
level=Qgis.Warning, duration=5) level=Qgis.Warning, duration=5)
return return


alg_parameters.append(parameters) alg_parameters.append(parameters)
Expand All @@ -139,8 +139,11 @@ def runAlgorithm(self):
for count, parameters in enumerate(alg_parameters): for count, parameters in enumerate(alg_parameters):
if feedback.isCanceled(): if feedback.isCanceled():
break break
self.setProgressText(QCoreApplication.translate('BatchAlgorithmDialog', '\nProcessing algorithm {0}/{1}…').format(count + 1, len(alg_parameters))) self.setProgressText(
self.setInfo(self.tr('<b>Algorithm {0} starting&hellip;</b>').format(self.algorithm().displayName()), escapeHtml=False) QCoreApplication.translate('BatchAlgorithmDialog', '\nProcessing algorithm {0}/{1}…').format(
count + 1, len(alg_parameters)))
self.setInfo(self.tr('<b>Algorithm {0} starting&hellip;</b>').format(self.algorithm().displayName()),
escapeHtml=False)
multi_feedback.setCurrentStep(count) multi_feedback.setCurrentStep(count)


parameters = self.algorithm().preprocessParameters(parameters) parameters = self.algorithm().preprocessParameters(parameters)
Expand All @@ -158,7 +161,9 @@ def runAlgorithm(self):
alg_start_time = time.time() alg_start_time = time.time()
ret, results = execute(self.algorithm(), parameters, context, multi_feedback) ret, results = execute(self.algorithm(), parameters, context, multi_feedback)
if ret: if ret:
self.setInfo(QCoreApplication.translate('BatchAlgorithmDialog', 'Algorithm {0} correctly executed…').format(self.algorithm().displayName()), escapeHtml=False) self.setInfo(
QCoreApplication.translate('BatchAlgorithmDialog', 'Algorithm {0} correctly executed…').format(
self.algorithm().displayName()), escapeHtml=False)
feedback.pushInfo( feedback.pushInfo(
self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - alg_start_time))) self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - alg_start_time)))
feedback.pushInfo(self.tr('Results:')) feedback.pushInfo(self.tr('Results:'))
Expand Down Expand Up @@ -209,5 +214,6 @@ def createSummaryTable(self, algorithm_results):
f.write('<p>{}: {}</p>\n'.format(out.description(), res[out.name()])) f.write('<p>{}: {}</p>\n'.format(out.description(), res[out.name()]))
f.write('<hr>\n') f.write('<hr>\n')


resultsList.addResult(self.algorithm().icon(), resultsList.addResult(icon=self.algorithm().icon(),
'{} [summary]'.format(self.algorithm().name()), outputFile) name='{} [summary]'.format(self.algorithm().name()), timestamp=time.localtime(),
result=outputFile)

0 comments on commit 66eabdd

Please sign in to comment.