christabor/flask_jsondash

Demo app is not compatible with Python 3.5

h4x3rotab opened this issue · 6 comments

According to the readme file, flash-jsondash should work with Python 3 but I had no luck to run the demo app. It complains the "dict_values" type doesn't support indexing access. Seems like a compatible issue.

Environment:

  • flask-jsondash 5.2.3
  • Python 3.5.2
  • macOS 10.12.4

Repro:

  1. Launch the demo app
# Start the mongodb daemon before start.
pip3 install flask-jsondash
git clone https://github.com/christabor/flask_jsondash.git
cd flask_jsondash/example_app
python3 app.py
python3 endpoints.py  # in another terminal.
  1. Navigate to http://127.0.0.1:8080/charts/ and create a new gird dashboard.

  2. Click Options > Edit raw JSON and paste the content of example_app/examples/config/fixedlayout-d3.json.

  3. Got the error:

File "/usr/local/lib/python3.5/site-packages/flask_jsondash/charts_builder.py", line 388, in view
modules=sort_modules(viewjson),

File "/usr/local/lib/python3.5/site-packages/flask_jsondash/charts_builder.py", line 311, in sort_modules
modules[int(module['row']) - 1].append(module)
TypeError: 'dict_values' object does not support indexing

let me take a look. ive corrected some of those errors but it's entirely possible some were missed. Thanks for the details!

Switched to Python 2.7 and mostly looks fine. However some demo configs are not valid JSON (e.g. trailing comma in the last element). I think it could be nice to have unittests for these configs.

good call. I'll make that a separate issue in
#123

I have tested on python3.5 32-bit for OSX, installed w/ pip3.5 install -e ., and am able to view the several demo dashboards without issue, as well as create a new one using the above referenced config (fixedlayout-d3.json). Are you still seeing this problem after pulling the latest changes? I don't think that would fixed it necessarily though, given it does not directly address the dict_values error. This particular line is converted to a python3.x compatible dict_values list already though, as the conversion happens a couple lines above on https://github.com/christabor/flask_jsondash/blob/master/flask_jsondash/charts_builder.py#L328

Thank you!

It turns out the version installed from pip is a bit out of date (5.2.3). This issue was fixed 4 days ago. I installed it from source and it works.

Excellent! don't hesitate to file an issue if you run into anything else.