Bug report #13830

Invalid scripts from models with advancedpythonfieldcalculator

Added by Anita Graser almost 5 years ago. Updated almost 5 years ago.

Assignee:Victor Olaya
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:21854


I've been testing the export model to script functionality. One models contains an Advanced Python Field Calculator.

The linebreaks in the Advanced Python Field Calculator python code cause the algorithm to fail.

2015-11-15T11:26:20    2    Uncaught error while executing algorithm
            Traceback (most recent call last):
              File "C:/OSGEO4~1/apps/qgis-dev/./python/plugins\\processing\\core\\GeoAlgorithm.py", line 230, in execute
              File "C:/OSGEO4~1/apps/qgis-dev/./python/plugins\\processing\\script\\ScriptAlgorithm.py", line 298, in processAlgorithm
                exec((script), ns)
              File "<string>", line 8
                outputs_QGISADVANCEDPYTHONFIELDCALCULATOR_1=processing.runalg('qgis:advancedpythonfieldcalculator', outputs_GRASSV.SPLIT.VERT_1['output'],'azimuth',0,3.0,0.0,None,'p1 = $geom.asPolyline()[0]
            SyntaxError: EOL while scanning string literal

Here's the script that is generated:

##Tanaka Contours=name
##tanakacontours=output vector
outputs_GDALOGRCONTOUR_1=processing.runalg('gdalogr:contour', RASTERLAYER_DEM,NUMBER_ELEVATIONINTERVALS,'ELEV',None,None)
outputs_GRASSV.SPLIT.VERT_1=processing.runalg('grass:v.split.vert', outputs_GDALOGRCONTOUR_1['OUTPUT_VECTOR'],2.0,None,-1.0,0.0001,0,None)
outputs_QGISADVANCEDPYTHONFIELDCALCULATOR_1=processing.runalg('qgis:advancedpythonfieldcalculator', outputs_GRASSV.SPLIT.VERT_1['output'],'azimuth',0,3.0,0.0,None,'p1 = $geom.asPolyline()[0]
p2 = $geom.asPolyline()[-1]
a = p1.azimuth(p2)
if a < 0:
   a += 360
value = a',tanakacontours)

Associated revisions

Revision 95b92c79
Added by Victor Olaya almost 5 years ago

[processing] correctly export multiline strings as python parameters from modeler

fixes #13830


#1 Updated by Victor Olaya almost 5 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF