Minimum needs error when loading a custom profile #2132

Closed
timlinux opened this Issue Jul 20, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@timlinux
Contributor

timlinux commented Jul 20, 2015

I get the following traceback when trying to open a project with Jakarta layers:

An error has occured while executing Python code:


Traceback (most recent call last):
  File "/Users/timlinux/.qgis2/python/plugins/inasafe/safe/gui/widgets/dock.py", line 775, in on_cboFunction_currentIndexChanged
    function = self.impact_function_manager.get(function_id)
  File "/Users/timlinux/.qgis2/python/plugins/inasafe/safe/impact_functions/impact_function_manager.py", line 102, in get
    return impact_functions[0].instance()
  File "/Users/timlinux/.qgis2/python/plugins/inasafe/safe/impact_functions/base.py", line 191, in instance
    return cls()
  File "/Users/timlinux/.qgis2/python/plugins/inasafe/safe/impact_functions/inundation/flood_polygon_population/impact_function.py", line 62, in __init__
    self.parameters = add_needs_parameters(self.parameters)
  File "/Users/timlinux/.qgis2/python/plugins/inasafe/safe/gui/tools/minimum_needs/needs_profile.py", line 34, in add_needs_parameters
    parameters['minimum needs'] = minimum_needs.get_needs_parameters()
  File "/Users/timlinux/.qgis2/python/plugins/inasafe/safe/gui/tools/minimum_needs/needs_profile.py", line 211, in get_needs_parameters
    if resource[element] is not None and '.' in resource[element]:
TypeError: argument of type 'float' is not iterable


Python version:
2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]


QGIS version:
2.8.2-Wien Wien, 

Python path: ['/Users/timlinux/.qgis2/python/plugins/processing', '/Applications/QGIS.app/Contents/MacOS/../Resources/python', u'/Users/timlinux/.qgis2/python', u'/Users/timlinux/.qgis2/python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/C/Python/2.7', '/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/numpy-override', '/Library/Python/2.7/site-packages/matplotlib-override', '/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg', '/Library/Python/2.7/site-packages/pycharm-debug.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', u'/Users/timlinux/.qgis2//python', '/Users/timlinux/.qgis2/python/plugins/inasafe', '/Users/timlinux/.qgis2/python/plugins/inasafe/safe_extras/parameters', '/Users/timlinux/.qgis2/python/plugins', '/Users/timlinux/.qgis2/python/plugins/inasafe/safe_extras', '/Users/timlinux/.qgis2/python/plugins/SGDiagramDownloader/third_party', '/Users/timlinux/.qgis2/python/plugins/StreamFeatureExtractor/third_party', '.', '/Applications/QGIS.app/Contents/Resources/python/plugins/fTools/tools', '/Users/timlinux/gisdata/Projects']

My JSON file was this.

{"profile": "dar", "provenance": "The minimum needs are based on Perka 7/2008.", "resources": [{"Resource name": "Rice", "Frequency": "weekly", "Default": 2.8, "Maximum allowed": 5.0, "Unit abbreviation": "kg", "Resource description": "Rice as a staple food", "Units": "kilograms", "Readable sentence": "A displaced person should be provided with {{ Default }} {{ Unit }}/{{ Units }}/{{ Unit abbreviation }} of {{ Resource name }}. Though no less than {{ Minimum allowed }} and no more than {{ Maximum allowed }}. This should be provided {{ Frequency }}.", "Minimum allowed": 1.0, "Unit": "kilogram"}]}

I was running master branch and the problem cannot be replicated on develop.

timlinux added a commit to timlinux/inasafe that referenced this issue Jul 20, 2015

timlinux added a commit to timlinux/inasafe that referenced this issue Jul 20, 2015

timlinux added a commit to timlinux/inasafe that referenced this issue Jul 20, 2015

timlinux added a commit that referenced this issue Jul 21, 2015

Merge pull request #2134 from timlinux/fix-2132
Fix #2132 - traceback on parsing custom minimum needs file
@ismailsunni

This comment has been minimized.

Show comment
Hide comment
@ismailsunni

ismailsunni Aug 24, 2015

Member

Hi @timlinux
Can you confirm it that you have fixed this one? If so, we can close this one. It's in changelog v 3.1.2

Member

ismailsunni commented Aug 24, 2015

Hi @timlinux
Can you confirm it that you have fixed this one? If so, we can close this one. It's in changelog v 3.1.2

timlinux added a commit to ismailsunni/inasafe that referenced this issue Aug 24, 2015

@timlinux timlinux closed this in 66f7c1f Aug 25, 2015

@timlinux timlinux removed the Needs review label Aug 25, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment