Skip to content

Commit

Permalink
Fix executing processing scripts through script editor
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 24, 2018
1 parent 0cc2956 commit 54f9846
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion python/plugins/processing/gui/ScriptEditorDialog.py
Expand Up @@ -274,7 +274,8 @@ def setHasChanged(self, hasChanged):

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:
Expand Down
7 changes: 5 additions & 2 deletions python/plugins/processing/script/ScriptAlgorithm.py
Expand Up @@ -79,7 +79,10 @@ def __init__(self, descriptionFile, script=None):
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
Expand Down Expand Up @@ -120,7 +123,7 @@ def defineCharacteristicsFromFile(self):
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()
Expand Down

0 comments on commit 54f9846

Please sign in to comment.