AIFDR / riab

Risk in a Box - main project
Other
17 stars 6 forks source link

Syntax errors in plugin requirements unclear #117

Open uniomni opened 13 years ago

uniomni commented 13 years ago

No idea what is wrong: Need better error message.

SyntaxError at /api/v1/functions/

Syntax error in plugin requirements header: def check(): layer_type = "feature" category = "exposure" class = "TestBLDGCl" subcategory = "building" title = "osm_080811" return category=="hazard" and subcategory.startswith("earthquake") and layer_type=="raster" and unit=="mmi"

Request Method: GET Request URL: http://127.0.0.1:8000/api/v1/functions/ Django Version: 1.3 Exception Type: SyntaxError Exception Value:

Syntax error in plugin requirements header: def check(): layer_type = "feature" category = "exposure" class = "TestBLDGCl" subcategory = "building" title = "osm_080811" return category=="hazard" and subcategory.startswith("earthquake") and layer_type=="raster" and unit=="mmi"

Exception Location: /home/dhutre/riskinabox/riab/impact/plugins/core.py in requirement_check, line 219 Python Executable: /home/dhutre/riskinabox/riab_env/bin/python Python Version: 2.6.6 Python Path:

['/usr/bin', '/home/dhutre/riskinabox/riab_env/lib/python2.6/site-packages/distribute-0.6.10-py2.6.egg', '/home/dhutre/riskinabox/riab_env/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg', '/home/dhutre/riskinabox/riab_env/src/gsconfig.py/src', '/home/dhutre/riskinabox/riab_env/src/nosexcover', '/home/dhutre/riskinabox/riab_env/src/owslib', '/home/dhutre/riskinabox/geonode/src/GeoNodePy', '/home/dhutre/riskinabox/riab', '/home/dhutre/riskinabox/riab_env/src/avatar', '/home/dhutre/riskinabox/riab_env/lib/python2.6', '/home/dhutre/riskinabox/riab_env/lib/python2.6/plat-linux2', '/home/dhutre/riskinabox/riab_env/lib/python2.6/lib-tk', '/home/dhutre/riskinabox/riab_env/lib/python2.6/lib-old', '/home/dhutre/riskinabox/riab_env/lib/python2.6/lib-dynload', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/home/dhutre/riskinabox/riab_env/lib/python2.6/site-packages', '/usr/local/lib/python2.6/site-packages', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0']

Server time: Thu, 11 Aug 2011 23:06:25 -0500

uniomni commented 13 years ago

The problem here was that one cannot use Python keywords such as 'class' Still need better reporting. Also, if a plugin has syntax errors in the body it prevents Risiko from starting. This is not good.

uniomni commented 13 years ago

As an example: Change the line H = H.interpolate(E) in e.g. BNPB_earthquake_guidelines.py to H = H.interpolate(E Then attempting a launch of Risiko gives a page with the message:

TemplateSyntaxError at /impact/

Caught SyntaxError while rendering: invalid syntax (BNPB_earthquake_guidelines.py, line 63)

Request Method: GET Request URL: http://127.0.0.1:8000/impact/ Django Version: 1.3.1 Exception Type: TemplateSyntaxError Exception Value:

Caught SyntaxError while rendering: invalid syntax (BNPB_earthquake_guidelines.py, line 63)

Exception Location: /home/nielso/dev/riab/impact/plugins/init.py in , line 15 Python Executable: /home/nielso/dev/riab_env/bin/python Python Version: 2.6.6