Skip to content
Permalink
Browse files

Report errors when executing algs within dialogs

  • Loading branch information
nyalldawson committed Jun 23, 2017
1 parent 93b7c28 commit 98617c90bdb63ed55ae58498a240d60d01b57f0c
Showing with 19 additions and 30 deletions.
  1. +11 −26 python/plugins/processing/core/GeoAlgorithm.py
  2. +8 −4 python/plugins/processing/gui/AlgorithmDialog.py
@@ -330,32 +330,17 @@ def executeAlgorithm(alg, parameters, context=None, feedback=None, model=None):
context = dataobjects.createContext()

#self.model = model
try:
#self.setOutputCRS()
#self.resolveOutputs()
#self.evaluateParameterValues()
#self.runPreExecutionScript(feedback)
result, ok = alg.run(parameters, context, feedback)
#self.processAlgorithm(parameters, context, feedback)
feedback.setProgress(100)
return result
#self.convertUnsupportedFormats(context, feedback)
#self.runPostExecutionScript(feedback)
except GeoAlgorithmExecutionException as gaee:
lines = [self.tr('Error while executing algorithm')]
lines = []
lines.append(traceback.format_exc())
feedback.reportError(gaee.msg)
QgsMessageLog.logMessage(gaee.msg, self.tr('Processing'), QgsMessageLog.CRITICAL)
raise GeoAlgorithmExecutionException(gaee.msg, lines, gaee)
#except Exception as e:
# If something goes wrong and is not caught in the
# algorithm, we catch it here and wrap it
#lines = [self.tr('Uncaught error while executing algorithm')]
# lines = []
# lines.append(traceback.format_exc())
#QgsMessageLog.logMessage('\n'.join(lines), self.tr('Processing'), QgsMessageLog.CRITICAL)
#raise GeoAlgorithmExecutionException(str(e) + self.tr('\nSee log for more details'), lines, e)

#self.setOutputCRS()
#self.resolveOutputs()
#self.evaluateParameterValues()
#self.runPreExecutionScript(feedback)
result, ok = alg.run(parameters, context, feedback)
#self.processAlgorithm(parameters, context, feedback)
feedback.setProgress(100)
return result, ok
#self.convertUnsupportedFormats(context, feedback)
#self.runPostExecutionScript(feedback)

def helpUrl(self):
return QgsHelp.helpUrl("processing_algs/{}/{}".format(
@@ -244,10 +244,14 @@ def accept(self):
if command:
ProcessingLog.addToLog(command)
self.buttonCancel.setEnabled(self.alg.flags() & QgsProcessingAlgorithm.FlagCanCancel)
result = executeAlgorithm(self.alg, parameters, context, feedback)
feedback.pushInfo(self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
feedback.pushInfo(self.tr('Results:'))
feedback.pushCommandInfo(pformat(result))
result, ok = executeAlgorithm(self.alg, parameters, context, feedback)
if ok:
feedback.pushInfo(self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
feedback.pushInfo(self.tr('Results:'))
feedback.pushCommandInfo(pformat(result))
else:
feedback.reportError(
self.tr('Execution failed after {0:0.2f} seconds'.format(time.time() - start_time)))
feedback.pushInfo('')

self.buttonCancel.setEnabled(False)

0 comments on commit 98617c9

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