mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-18 00:06:00 -04:00
Fix executing processing scripts through script editor
This commit is contained in:
parent
0cc29569f5
commit
54f9846eda
@ -274,7 +274,8 @@ class ScriptEditorDialog(BASE, WIDGET):
|
|||||||
|
|
||||||
def runAlgorithm(self):
|
def runAlgorithm(self):
|
||||||
if self.algType == self.SCRIPT_PYTHON:
|
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)
|
dlg = alg.createCustomParametersWidget(self)
|
||||||
if not dlg:
|
if not dlg:
|
||||||
|
@ -79,7 +79,10 @@ class ScriptAlgorithm(QgsProcessingAlgorithm):
|
|||||||
self.results = {}
|
self.results = {}
|
||||||
|
|
||||||
def createInstance(self):
|
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):
|
def initAlgorithm(self, config=None):
|
||||||
pass
|
pass
|
||||||
@ -120,7 +123,7 @@ class ScriptAlgorithm(QgsProcessingAlgorithm):
|
|||||||
try:
|
try:
|
||||||
self.processParameterLine(line.strip('\n'))
|
self.processParameterLine(line.strip('\n'))
|
||||||
except:
|
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)
|
'Problem with line: {0}', 'ScriptAlgorithm').format(line)
|
||||||
self.script += line
|
self.script += line
|
||||||
line = lines.readline()
|
line = lines.readline()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user