Weewx cheetahgenerator / template bug: how to debug?

175 views
Skip to first unread message

Invisible Man

unread,
Aug 21, 2023, 2:29:08 AM8/21/23
to weewx-user
Hello,
I occasionally have an error in my Weewx logs that indicate that, at some point, I receive for a given value the value None where I was expected an int. Because of this error, cheetahgenerator fails to produce the correct HTML file.

```
Aug 21 00:02:29 vegan weewx[20951] ERROR weewx.cheetahgenerator: Evaluation of template /home/weewx/skins/External/index.html.tmpl failed with exception '<class 'TypeError'>'
Aug 21 00:02:29 vegan weewx[20951] ERROR weewx.cheetahgenerator: **** Ignoring template /home/weewx/skins/External/index.html.tmpl
Aug 21 00:02:29 vegan weewx[20951] ERROR weewx.cheetahgenerator: **** Reason: '>' not supported between instances of 'NoneType' and 'int'
Aug 21 00:02:29 vegan weewx[20951] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Aug 21 00:02:29 vegan weewx[20951] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/cheetahgenerator.py", line 348, in generate
Aug 21 00:02:29 vegan weewx[20951] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
Aug 21 00:02:29 vegan weewx[20951] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_External_index_html_tmpl.py", line 317, in respond
Aug 21 00:02:29 vegan weewx[20951] ERROR weewx.cheetahgenerator: ****  TypeError: '>' not supported between instances of 'NoneType' and 'int'
Aug 21 00:06:22 vegan weewx[20951] ERROR weewx.cheetahgenerator: Evaluation of template /home/weewx/skins/External/index.html.tmpl failed with exception '<class 'TypeError'>'
Aug 21 00:06:22 vegan weewx[20951] ERROR weewx.cheetahgenerator: **** Ignoring template /home/weewx/skins/External/index.html.tmpl
```

The problem might be in my template - something like a value which is not protected by a call to "has_data". Ideally, I would like to know at which line it fails in the template, or which data is the cause. Is there a way to do that ?

I already have `debug =1` in my config.
I am running Weewx 4.10.2 on a Raspberry Pi.

Thanks,
Axelle 

michael.k...@gmx.at

unread,
Aug 21, 2023, 6:10:29 AM8/21/23
to weewx-user

The problem is in /home/weewx/skins/External/index.html.tmpl
There is a comparision (greater than) between two values, where one of them (the left) is None.

something like:

#if $val > $other

Where $val is None and $other an integer. Where is the template from, who made it? 

When it happens occasionally, probably some obs_type has no reading and the template doesn't take this into account. This might or might not be unexpected, for the windDir, for instance, it is perfectly correct to have None as the value, when the windSpeed is 0.

Karen K

unread,
Aug 21, 2023, 12:33:37 PM8/21/23
to weewx-user


michael.k...@gmx.at schrieb am Montag, 21. August 2023 um 12:10:29 UTC+2:
#if $val > $other

And you could change it to:

#if $val is not None and $val>$other

or

#if $val is None or $val>$other

depending on what you want to do with the None value. 

Invisible Man

unread,
Aug 22, 2023, 3:45:15 AM8/22/23
to weewx-user
Yes, I customized that template myself. The issue is occasional, so for some reason, sometimes that value has no reading. As the template is a bit long, I was wondering if there was a solution to pin down the exact location of the bug, but I'll just add a condition testing for None before in all situations.
Thanks.

michael.k...@gmx.at

unread,
Aug 22, 2023, 3:50:35 AM8/22/23
to weewx-user

Invisible Man

unread,
Aug 22, 2023, 3:56:06 AM8/22/23
to weewx-user
>Try adding 
>#errorCatcher Echo
>to the template

Nice! Thanks!
Reply all
Reply to author
Forward
0 new messages