long_form and time context

24 views
Skip to first unread message

Karen K

unread,
Apr 16, 2023, 2:50:19 PM4/16/23
to weewx-development
I see that I cannot set an appropriate time context if I use long_form together with $current.  This is if the observation type itself is of group_deltatime. I tried $current.obstype.long_form(context='week'), but that did not work.

Vince Skahan

unread,
Apr 16, 2023, 3:44:00 PM4/16/23
to weewx-development
On Sunday, April 16, 2023 at 11:50:19 AM UTC-7 Karen K wrote:
I tried $current.obstype.long_form(context='week'), but that did not work.

We would have to see cheetah template line that is failing as well as your syslog errors....



Karen K

unread,
Apr 17, 2023, 10:17:16 AM4/17/23
to weewx-development
There is no parameter `context` in `long_form`. So it is clear that the example can not work. 

Consequently the error log looks like that:

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: Evaluation of template /etc/weewx/skins/Belchertown1_3/index.html.tmpl failed with exception '<class 'TypeError'>'

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: **** Ignoring template /etc/weewx/skins/Belchertown1_3/index.html.tmpl

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: **** Reason: long_form() got an unexpected keyword argument 'context'

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/cheetahgenerator.py", line 348, in generate

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: ****    File "cheetah__etc_weewx_skins_Belchertown1_3_index_html_tmpl_1681669818_8877633_12239.py", line 1852, in respond

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1708, in _handleCheetahInclude

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: ****      self._CHEETAH__cheetahIncludes[_includeID].respond(trans)

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: ****    File "cheetah__etc_weewx_skins_Belchertown1_3_index_hook_after_charts_inc_1681670418_9296255_76052.py", line 406, in respond

Apr 16 20:40:18 LokalWiki weewx[116925] ERROR weewx.cheetahgenerator: ****  TypeError: long_form() got an unexpected keyword argument 'context'


Tom Keffer

unread,
Apr 17, 2023, 11:45:28 AM4/17/23
to Karen K, weewx-development
There is no parameter 'context' for long_form(), but you can specify a 'format'. I'm not sure what problem you're trying to solve, but if it's that you need formatting for a week, while $current assumes something less than a day, try

$current.obstype.long_form(format="%(day)d%(day_label)s, %(hour)d%(hour_label)s, %(minute)d%(minute_label)s")

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/5925305e-a9fb-4c20-a686-52c7a56b9120n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages