Template error python 3.9 vs. 3.7?

47 views
Skip to first unread message

Copain

unread,
Nov 12, 2022, 10:56:37 AM11/12/22
to weewx-user
Many thanks for the continuous develompent of the weewx weather software.

Currently I am testing weewx 4.9.1 with python 3.9.2 in a virtual machine.
My life system runs weewx 4.4.0 with python 3.7.3.

On the virtual machine, one of my templates generates the following error:
TypeError: '<' not supported between instances of 'NoneType' and 'int'

Probably the error originates from either of this code:
#if $day.wind.vecdir.raw is not None and $day.windSpeed.max.raw is not 0
#if $day.wind.gustdir.raw is not None and $day.wind.max.raw is not 0

Is the error handling different in the 2 python or weewx versions?
Or could it come from wind.vecdir which - I believe - is not on the weewx sqlite3 database?

How should I correct the code to avoid the error?

Any help would be appreciated.
Thank you.

Tom Keffer

unread,
Nov 12, 2022, 12:49:41 PM11/12/22
to weewx...@googlegroups.com
Finding errors raised by the Cheetah template engine can be very difficult. It does not give a lot of useful information.

However, the error did not come from the two lines you posted. We can be sure of that because they did not use the operator '<'.

Look for a line that uses the less than operator. I would also guess that it will have a variable on the left side of the operator, and an integer on the right. Something like "x < 2".

If all else fails, what I do is split the template in half and see if I get an error. If so, I know which half it's in. Split again in half, and so on. Eventually you will isolate it down to the offending line.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/15b78b92-f1c8-49c6-b3e7-946094aee77dn%40googlegroups.com.

Copain

unread,
Nov 12, 2022, 3:14:12 PM11/12/22
to weewx-user
Tom, thank you very much for your support.

You are right. The error comes from
$trend.outTemp.raw < 0
$trend.barometer.raw < 0
$trend.inTemp.raw < 0
with a new empty weewx sqlite3 database.

I enclosed these in an 'if is not None' statement and replaced all 'is not' with '!=' at the same time, because I got syntax warnings.

For information, how long does it take with a new empty weewx sqlite3 database until first trend values become available?
Reply all
Reply to author
Forward
0 new messages