Is last not always valid? I assumed it would give the last value, whether it was 10 seconds ago, or 2 hours ago.
On Jun 30, 2017 7:50 PM, "Thomas Keffer" <[email protected]> wrote: > There must not have been a valid value for outTemp for the given value of > timespan in the first call. You can check for yourself by printing out > timespan, then looking in your database for the day starting with the > printed starting time. > > -tk > > On Fri, Jun 30, 2017 at 6:45 PM, Thomas Carlin <[email protected]> > wrote: > >> 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]> >>> 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]. >>>> 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. >> > > -- > 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/P0emh6GW40I/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.
