andreasgerstmayr / fava-dashboards

Custom Dashboards for Beancount in Fava
MIT License
178 stars 21 forks source link

Example does not run on windows (fava 1.24.4 python 3.10) #3

Closed IguanaBen closed 1 year ago

IguanaBen commented 1 year ago

I'm running fava 1.24.4 and beancount 2.3.5 on windows 11 with python 3.10. If I clone this repository and open the fava-dashboards/example direction and run

fava example.beancount

then when I go to the dashboard page on my web browser, I get the following error

$ fava example.beancount
Starting Fava on http://127.0.0.1:5000
Exception on /beancount/extension/FavaDashboards/ [GET]
Traceback (most recent call last):
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1525, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\fava\application.py", line 370, in extension_report
    content = Markup(render_template_string(template, extension=extension))
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\templating.py", line 166, in render_template_string
    return _render(ctx.app.jinja_env.from_string(source), context, ctx.app)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\templating.py", line 128, in _render
    rv = template.render(context)
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\jinja2\environment.py", line 1291, in render
    self.environment.handle_exception()
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\jinja2\environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 6, in top-level template code
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\fava_dashboards\__init__.py", line 21, in static_file
    return f.read()
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 183817: character maps to <undefined>

I tried downgrading to fava 1.22 since they made a few changes to the rendering engine that could break plugins, but I get the same error either way.

Thanks,

andreasgerstmayr commented 1 year ago

Hi @IguanaBen,

thanks for the bug report. I don't have a Windows machine to test, but I think I know what's the issue. Could you test the changes here: https://github.com/andreasgerstmayr/fava-dashboards/pull/4/files and report if these resolve the error?

Thanks

IguanaBen commented 1 year ago

Thanks for the quick response. That moves the error as I no longer get it in the terminal. Instead when I go to the FavaDashboards url, I get the proper fava page and sidebar, but the main window where the dashboard should be just displays the error message:

Cannot read configuration file C:\Users\username\repos\fava-dashboards\example\dashboards.yaml: 'charmap' codec can't decode byte 0x8f in position 4561: character maps to <undefined>
IguanaBen commented 1 year ago

Ok, I must have done something wrong, because I tried again with your patch and it works great. Thanks!

andreasgerstmayr commented 1 year ago

Awesome, thanks for reporting back!