Fix executing processing scripts through script editor

This commit is contained in:
Nyall Dawson 2018-01-24 14:16:44 +10:00
parent 0cc29569f5
commit 54f9846eda
2 changed files with 7 additions and 3 deletions

View File

@ -274,7 +274,8 @@ class ScriptEditorDialog(BASE, WIDGET):
def runAlgorithm(self):
if self.algType == self.SCRIPT_PYTHON:
alg = ScriptAlgorithm(None, self.editor.text())
alg = ScriptAlgorithm(None, script=self.editor.text())
alg.setProvider(QgsApplication.processingRegistry().providerById('script'))
dlg = alg.createCustomParametersWidget(self)
if not dlg:

View File

@ -79,7 +79,10 @@ class ScriptAlgorithm(QgsProcessingAlgorithm):
self.results = {}
def createInstance(self):
return ScriptAlgorithm(self.descriptionFile)
if self.descriptionFile is not None:
return ScriptAlgorithm(self.descriptionFile)
else:
return ScriptAlgorithm(descriptionFile=None, script=self.script)
def initAlgorithm(self, config=None):
pass
@ -120,7 +123,7 @@ class ScriptAlgorithm(QgsProcessingAlgorithm):
try:
self.processParameterLine(line.strip('\n'))
except:
self.error = self.tr('This script has a syntax errors.\n'
self.error = self.tr('This script has a syntax error.\n'
'Problem with line: {0}', 'ScriptAlgorithm').format(line)
self.script += line
line = lines.readline()