Dear Thommas, Once more you impressed me a lot, such quick and well formed answer. Thanks.
Now I am afraid to say that there is still a buf, probably a typo or some thing like that. I checked "my" additions in "extensions.py" and "almanac.py" (and of course in "index.html.tmpl"), and believe they were correctly done. Just a question: where can I find the generated file "cheetah__etc_weewx_skins_Standard_index_html_tmpl_1548001524_26_16364.py" ? Here is the .log of the error: reportengine: Found configuration file /etc/weewx/skins/Standard/skin.conf for report StandardReport cheetahgenerator: using search list ['weewx.cheetahgenerator.Almanac', 'weewx.cheetahgenerator.Station', 'weewx.cheetahgenerator.Current', 'weewx.cheetahgenerator.Stats', 'weewx.cheetahgenerator.UnitInfo', 'weewx.cheetahgenerator.Extras'] manager: Daily summary version is 2.0 cheetahgenerator: Generate failed with exception '<type 'exceptions.TypeError'>' cheetahgenerator: **** Ignoring template /etc/weewx/skins/Standard/index.html.tmpl cheetahgenerator: **** Reason: 'ephem.EllipticalBody' object is not callable **** Traceback (most recent call last): **** File "/usr/share/weewx/weewx/cheetahgenerator.py", line 330, in generate **** print >> _file, compiled_template **** File "/usr/lib/python2.7/dist-packages/Cheetah/Template.py", line 1005, in __str__ **** rc = getattr(self, mainMethName)() **** File "cheetah__etc_weewx_skins_Standard_index_html_tmpl_1548001524_26_16364.py", line 2545, in respond **** File "cheetah__etc_weewx_skins_Standard_index_html_tmpl_1548001524_26_16364.py", line 1155, in __errorCatcher156 **** File "<string>", line 1, in <module> **** File "/usr/share/weewx/weewx/almanac.py", line 355, in __getattr__ **** ephem_body = _get_ephem_body(self.heavenly_body) **** File "/usr/share/weewx/weewx/almanac.py", line 424, in _get_ephem_body **** ephem_body = getattr(ephem, cap_name)() **** TypeError: 'ephem.EllipticalBody' object is not callable cheetahgenerator: Generated 13 files for report StandardReport in 0.56 seconds manager: Daily summary version is 2.0 Best regards, Paul Le dim. 20 janv. 2019 à 01:28, Thomas Keffer <[email protected]> a écrit : > This is a good question, and it took me a while to figure out how to work > around the limitations of pyephem. Try this: > > 1. Put the following in user/extensions.py: > > import ephem > eros = ephem.readdb("433 > Eros,e,10.8276,304.3222,178.8165,1.457940,0.5598795,0.22258902,71.2803,09/04.0/2017,2000,H11.16,0.46") > ephem.Eros = eros > > 2. Modify the WeeWX module weewx/almanac.py so that the function > _get_ephem_body() looks like this: > > def _get_ephem_body(heavenly_body): > # The library 'ephem' refers to heavenly bodies using a capitalized > # name. For example, the module used for 'mars' is 'ephem.Mars'. > cap_name = heavenly_body.capitalize() > > # If the heavenly body is a star, or if the body does not exist, then > an > # exception will be raised. Be prepared to catch it. > try: > ephem_body = getattr(ephem, cap_name)() > except AttributeError: > # That didn't work. Try a star. If this doesn't work either, > # then a KeyError exception will be raised. > ephem_body = ephem.star(cap_name) > except TypeError: > ephem_body = getattr(ephem, cap_name) > > return ephem_body > > You are adding the two highlighted lines. > > 3. Then use this in your template: > > $almanac.eros.rise > > for when it rises, etc. (treat it just like any other planet). > > Double check the answer. I'm not 100% confident this will work. If it > does, I'll add the changes for weewx/almanac.py to the code base. > > -tk > > On Sat, Jan 19, 2019 at 10:20 AM Paul Bartholdi <[email protected]> > wrote: > >> Hi, >> >> I nodified a few years ago the "Standard/index.html.tmpl" to print the >> main solar systems objects (sun, moon, Jupiter...). >> Now I want to pint the same informations but for the minor planet Eros >> that pass very (very relative!) the earth in the few next days. >> This implies adding the python line: >> >> eros = ephem.readdb("433 >> Eros,e,10.8276,304.3222,178.8165,1.457940,0.5598795,0.22258902,71.2803,09/04.0/2017,2000,H11.16,0.46") >> >> and then (in index.html.tmp) : >> >> <tr> >> <td class="label">Rise :</td> >> <td class="data">$almanac.eros.rise</td> >> </tr> >> >> Where should I add the " eros = ephem.readdb(...) line ? ( >> index.html.tmpl ? almanac.py ? elsewhere ?). >> >> Thanks for any help/advice! Paul >> >> >> -- >> 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 [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "weewx-user" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/weewx-user/XdRQgtqWfFo/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
