Skip to content
Permalink
Browse files
[processing] cleaned up options (threaded execution and table-like pa…
…rameters dialog
  • Loading branch information
volaya committed Sep 15, 2013
1 parent a5f0e4b commit 048c26a1f3e3241a0a86bd1ab0dfea4d9f906fa2
@@ -159,7 +159,7 @@ def execute(self, progress, model = None):
except GeoAlgorithmExecutionException, gaee:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, gaee.msg)
raise gaee
except:
except Exception, e:
#if something goes wrong and is not caught in the algorithm,
#we catch it here and wrap it
lines = ["Uncaught error while executing algorithm"]
@@ -171,7 +171,7 @@ def execute(self, progress, model = None):
lines.append(errstring)
lines.append(errstring.replace("\n", "|"))
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, lines)
raise GeoAlgorithmExecutionException(errstring)
raise GeoAlgorithmExecutionException(str(e))


def runPostExecutionScript(self, progress):
@@ -34,11 +34,9 @@
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.ProcessingLog import ProcessingLog
from processing.gui.AlgorithmClassification import AlgorithmDecorator
from processing.gui.AlgorithmExecutor import AlgorithmExecutor
from processing.gui.RenderingStyles import RenderingStyles
from processing.gui.Postprocessing import Postprocessing
from processing.gui.UnthreadedAlgorithmExecutor import UnthreadedAlgorithmExecutor
from processing.core.SilentProgress import SilentProgress
from processing.modeler.Providers import Providers
from processing.modeler.ModelerAlgorithmProvider import ModelerAlgorithmProvider
from processing.modeler.ModelerOnlyAlgorithmProvider import ModelerOnlyAlgorithmProvider
@@ -310,45 +308,12 @@ def runAlgorithm(algOrName, onFinish, *args):
elif cursor.shape() != Qt.WaitCursor:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

useThreads = ProcessingConfig.getSetting(ProcessingConfig.USE_THREADS)

#this is doing strange things, so temporarily the thread execution is disabled from the console
useThreads = False

if useThreads:
algEx = AlgorithmExecutor(alg)
progress = QProgressDialog()
progress.setWindowTitle(alg.name)
progress.setLabelText("Executing %s..." % alg.name)
def finish():
QApplication.restoreOverrideCursor()
if onFinish is not None:
onFinish(alg, SilentProgress())
progress.close()
def error(msg):
QApplication.restoreOverrideCursor()
print msg
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, msg)
def cancel():
try:
algEx.finished.disconnect()
algEx.terminate()
QApplication.restoreOverrideCursor()
progress.close()
except:
pass
algEx.error.connect(error)
algEx.finished.connect(finish)
algEx.start()
algEx.wait()
else:
#progress = SilentProgress()
progress = MessageBarProgress()
ret = UnthreadedAlgorithmExecutor.runalg(alg, progress)
if onFinish is not None and ret:
onFinish(alg, progress)
QApplication.restoreOverrideCursor()
progress.close()
progress = MessageBarProgress()
ret = UnthreadedAlgorithmExecutor.runalg(alg, progress)
if onFinish is not None and ret:
onFinish(alg, progress)
QApplication.restoreOverrideCursor()
progress.close()
return alg


@@ -29,7 +29,6 @@

class ProcessingConfig():

TABLE_LIKE_PARAM_PANEL = "TABLE_LIKE_PARAM_PANEL"
OUTPUT_FOLDER = "OUTPUT_FOLDER"
RASTER_STYLE = "RASTER_STYLE"
VECTOR_POINT_STYLE = "VECTOR_POINT_STYLE"
@@ -39,7 +38,6 @@ class ProcessingConfig():
USE_SELECTED = "USE_SELECTED"
USE_FILENAME_AS_LAYER_NAME = "USE_FILENAME_AS_LAYER_NAME"
KEEP_DIALOG_OPEN = "KEEP_DIALOG_OPEN"
USE_THREADS = "USE_THREADS"
SHOW_DEBUG_IN_DIALOG = "SHOW_DEBUG_IN_DIALOG"
RECENT_ALGORITHMS = "RECENT_ALGORITHMS"
PRE_EXECUTION_SCRIPT = "PRE_EXECUTION_SCRIPT"
@@ -54,11 +52,9 @@ class ProcessingConfig():
def initialize():
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
ProcessingConfig.settingIcons["General"] = icon
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.USE_THREADS, "Run algorithms in a new thread (unstable)", False))
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.SHOW_DEBUG_IN_DIALOG, "Show extra info in Log panel", True))
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.KEEP_DIALOG_OPEN, "Keep dialog open after running an algorithm", False))
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.USE_SELECTED, "Use only selected features", True))
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.TABLE_LIKE_PARAM_PANEL, "Show table-like parameter panels", False))
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.USE_SELECTED, "Use only selected features", True))
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.USE_FILENAME_AS_LAYER_NAME, "Use filename as layer name", False))
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.SHOW_RECENT_ALGORITHMS, "Show recently executed algorithms", True))
ProcessingConfig.addSetting(Setting("General", ProcessingConfig.OUTPUT_FOLDER, "Output folder", tempFolder()))
@@ -37,12 +37,10 @@
from processing.parameters.ParameterFixedTable import ParameterFixedTable
from processing.parameters.ParameterTableField import ParameterTableField
from processing.parameters.ParameterTable import ParameterTable
from processing.gui.AlgorithmExecutor import AlgorithmExecutor
from processing.core.ProcessingLog import ProcessingLog
from processing.gui.Postprocessing import Postprocessing
from processing.parameters.ParameterRange import ParameterRange
from processing.parameters.ParameterNumber import ParameterNumber

from processing.parameters.ParameterFile import ParameterFile
from processing.parameters.ParameterCrs import ParameterCrs
from processing.core.ProcessingConfig import ProcessingConfig
@@ -75,11 +73,7 @@ def __init__(self, alg, mainWidget):
self.runButton = QtGui.QPushButton()
self.runButton.setText("Run")
self.buttonBox.addButton(self.runButton, QtGui.QDialogButtonBox.ActionRole)
self.runButton.clicked.connect(self.accept)
self.scrollArea = QtGui.QScrollArea()
if self.mainWidget:
self.scrollArea.setWidget(self.mainWidget)
self.scrollArea.setWidgetResizable(True)
self.runButton.clicked.connect(self.accept)
self.setWindowTitle(self.alg.name)
self.progressLabel = QtGui.QLabel()
self.progress = QtGui.QProgressBar()
@@ -91,7 +85,7 @@ def __init__(self, alg, mainWidget):
self.verticalLayout.setMargin(0)
self.tabWidget = QtGui.QTabWidget()
self.tabWidget.setMinimumWidth(300)
self.tabWidget.addTab(self.scrollArea, "Parameters")
self.tabWidget.addTab(self.mainWidget, "Parameters")
self.verticalLayout.addWidget(self.tabWidget)
self.logText = QTextEdit()
self.logText.readOnly = True
@@ -146,9 +140,8 @@ def setParamValues(self):
if output.hidden:
continue
output.value = self.paramTable.valueItems[output.name].getValue()
if not ProcessingConfig.getSetting(ProcessingConfig.TABLE_LIKE_PARAM_PANEL):
if isinstance(output, (OutputRaster, OutputVector, OutputTable)):
output.open = self.paramTable.checkBoxes[output.name].isChecked()
if isinstance(output, (OutputRaster, OutputVector, OutputTable)):
output.open = self.paramTable.checkBoxes[output.name].isChecked()

return True

@@ -192,8 +185,7 @@ def setParamValue(self, param, widget):
@pyqtSlot()
def accept(self):
checkCRS = ProcessingConfig.getSetting(ProcessingConfig.WARN_UNMATCHING_CRS)
keepOpen = ProcessingConfig.getSetting(ProcessingConfig.KEEP_DIALOG_OPEN)
useThread = ProcessingConfig.getSetting(ProcessingConfig.USE_THREADS)
keepOpen = ProcessingConfig.getSetting(ProcessingConfig.KEEP_DIALOG_OPEN)
self.showDebug = ProcessingConfig.getSetting(ProcessingConfig.SHOW_DEBUG_IN_DIALOG)
try:
self.setParamValues()
@@ -224,46 +216,29 @@ def accept(self):
self.progress.setMaximum(0)
self.progressLabel.setText("Processing algorithm...")
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
if useThread and not self.iterateParam: #iterative execution on separate thread is still not working fine...

self.setInfo("<b>Algorithm %s starting...</b>" % self.alg.name)
if self.iterateParam:
if UnthreadedAlgorithmExecutor.runalgIterating(self.alg, self.iterateParam, self):
self.finish()
else:
QApplication.restoreOverrideCursor()
if not keepOpen:
self.close()
else:
self.resetGUI()
else:
command = self.alg.getAsCommand()
if command:
ProcessingLog.addToLog(ProcessingLog.LOG_ALGORITHM, command)
self.algEx = AlgorithmExecutor(self.alg)
self.algEx.algExecuted.connect(self.finish)
self.algEx.error.connect(self.error)
self.algEx.percentageChanged.connect(self.setPercentage)
self.algEx.textChanged.connect(self.setText)
self.algEx.iterated.connect(self.iterate)
self.algEx.infoSet.connect(self.setInfo)
self.algEx.commandSet.connect(self.setCommand)
self.algEx.debugInfoSet.connect(self.setDebugInfo)
self.algEx.consoleInfoSet.connect(self.setConsoleInfo)
self.algEx.start()
self.setInfo("<b>Algorithm %s started</b>" % self.alg.name)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(True)
else:
self.setInfo("<b>Algorithm %s starting...</b>" % self.alg.name)
if self.iterateParam:
if UnthreadedAlgorithmExecutor.runalgIterating(self.alg, self.iterateParam, self):
self.finish()
else:
QApplication.restoreOverrideCursor()
if not keepOpen:
self.close()
else:
self.resetGUI()
if UnthreadedAlgorithmExecutor.runalg(self.alg, self):
self.finish()
else:
command = self.alg.getAsCommand()
if command:
ProcessingLog.addToLog(ProcessingLog.LOG_ALGORITHM, command)
if UnthreadedAlgorithmExecutor.runalg(self.alg, self):
self.finish()
QApplication.restoreOverrideCursor()
if not keepOpen:
self.close()
else:
QApplication.restoreOverrideCursor()
if not keepOpen:
self.close()
else:
self.resetGUI()
self.resetGUI()
except AlgorithmExecutionDialog.InvalidParameterValue as ex:
try:
self.buttonBox.accepted.connect(lambda: ex.widget.setPalette(QPalette()))

This file was deleted.

Loading

0 comments on commit 048c26a

Please sign in to comment.