I am specifically wondering why it gets N/A the first time, and I have seen it for up to the first 3 results, and never get a value the first time. Why does the query not report the first time it is run?
On Friday, June 30, 2017 at 7:36:07 PM UTC-6, Tom Keffer wrote: > > I'm not sure what you're asking. Why did it print 44.1°F six times? If so, > this is exactly what Gary and I were discussing earlier: your extension > gets loaded once *for each template*. So, that's six calls to > get_extension_list() and six prints of 44.1°F. > > How often the extension gets used in the template is an entirely different > matter. > > For example, if you take out your line stats.day().outTemp.last, but put > a print statement in, say, TimespanBinder.__getattr__, nothing will get > printed unless the tag appears in your template. > > Does that help? > > -tk > > > > On Fri, Jun 30, 2017 at 5:38 PM, Thomas Carlin <[email protected] > <javascript:>> wrote: > >> Okay, so I distilled the code down to the bare minimum, and still get the >> same results, (returning N/A the first time it runs for each report cycle), >> and have included it below. I know that this SLE doesn't actually add >> anything, but since it has the same symptoms I am trying to diagnose, it >> should be a bit easier. >> >> from weewx.cheetahgenerator import SearchList >> >> from weewx.tags import TimespanBinder >> from weeutil.weeutil import TimeSpan >> import weeutil.weeutil >> import weewx.tags >> >> >> class GarageDoorAnalyzer(SearchList): >> def __init__(self, generator): >> SearchList.__init__(self, generator) >> >> self.search_list_extension = {} >> >> def get_extension_list(self, timespan, db_lookup): >> >> garagedoor_options = {'outTemp' : 'outTemp'} >> >> stats = weewx.tags.TimeBinder( >> db_lookup, >> timespan.stop, >> formatter=self.generator.formatter, >> converter=self.generator.converter) >> >> latest = stats.day().outTemp.last >> >> print latest >> >> return [self.search_list_extension] >> >> >> This little bit of code produces the output, It is essentially the same >> run though the main engine, just intertwined with loop packet output: >> sudo wee_reports /etc/weewx/weewx.conf >> Using configuration file /etc/weewx/weewx.conf >> Generating for all time >> N/A >> 44.1°F >> 44.1°F >> 44.1°F >> 44.1°F >> 44.1°F >> 44.1°F >> >> >> There is nothing in syslog or messages during this time. This 'server' >> this is running on is a Raspberry Pi 1, could it be lack of resources? >> >> Gary, your getattr code was exactly what I needed, and worked perfectly. >> >> Thank you all! >> >> Thomas >> >> >> On Friday, June 30, 2017 at 2:01:52 PM UTC-6, gjr80 wrote: >>> >>> Seeing the code and the context in which it is used is probably a good >>> starting point. >>> >>> Gary >>> >> -- >> 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] <javascript:>. >> 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.
