I tried your file mstats.py on my machine, and it worked fine. Perhaps it is a PYTHONPATH problem?
On Sun, Jul 26, 2020 at 2:00 AM Mike Hawkins <duckris...@gmail.com> wrote: > Hi, > I'm hoping somebody can point out what I'm doing wrong here, it's probably > trivial but I'm tearing my hair out and have no idea where things are going > wrong. > > I have several stations and therefore several databases, so I wanted a > version of the $alltime tag provided by the example stats.py or xstats.py > that would take a data_binding. With some searching I came up with this > > > """ > """ > > import weewx.units > from weewx.cheetahgenerator import SearchList > from weewx.tags import TimespanBinder, TimeBinder > from weeutil.weeutil import TimeSpan > > > class MyStats(SearchList): > > def __init__(self, generator): > SearchList.__init__(self, generator) > > def get_extension_list(self, timespan, db_lookup): > > class DBBinder(TimeBinder): > > # "alltime", with optional parameter data_binding > def alltime(self, data_binding=None): > return TimespanBinder(timespan, > self.db_lookup, > context='year', > data_binding=data_binding, > formatter=self.formatter, > converter=self.converter) > > binder = DBBinder(db_lookup, > timespan, > self.generator.formatter, > self.generator.converter) > return [binder] > > which works perfectly if the report is generated via wee_reports. > However it fails in the normal report run with: > > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: Caught > unrecoverable exception in generator > 'weewx.cheetahgenerator.CheetahGenerator' > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** name 'weewx' is not defined > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** Traceback (most recent call last): > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** File "/weewx/package/weewx-4.1.0/bin/weewx/reportengine.py", line > 197, in run > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** obj.start() > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** File "/weewx/package/weewx-4.1.0/bin/weewx/reportengine.py", line > 280, in start > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** self.run() > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** File "/weewx/package/weewx-4.1.0/bin/weewx/cheetahgenerator.py", > line 150, in run > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** ngen = self.generate(gen_dict[section_name], self.gen_ts) > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** File "/weewx/package/weewx-4.1.0/bin/weewx/cheetahgenerator.py", > line 220, in generate > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** ngen += self.generate(section[subsection], gen_ts) > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** File "/weewx/package/weewx-4.1.0/bin/weewx/cheetahgenerator.py", > line 220, in generate > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** ngen += self.generate(section[subsection], gen_ts) > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** File "/weewx/package/weewx-4.1.0/bin/weewx/cheetahgenerator.py", > line 308, in generate > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** searchList = self._getSearchList(encoding, timespan, > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** File "/weewx/package/weewx-4.1.0/bin/weewx/cheetahgenerator.py", > line 376, in _getSearchList > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** searchList += obj.get_extension_list(timespan, db_lookup) > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** File "/weewx/package/weewx-4.1.0/bin/user/mstats.py", line 18, in > get_extension_list > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** NameError: name 'weewx' is not defined > Jul 26 09:50:17 bee weewx-weewx[192470] ERROR weewx.reportengine: > **** Generator terminated > Jul 26 09:50:17 bee weewx-weewx[192470] INFO weewx.reportengine: Copied 0 > files to /weewx/www/live > > > Other than this problem my weewx config is quite happy and the other > extensions are working fine so I don't think there is anything > fundamentally wrong with my setup even though it is in a non-standard > location. > > Any pointers very gratefully received. > > Best > > Mike > > https://duckrising.com/weewx/ > > -- > 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-development+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-development/baafe0ef-59d5-4de4-80e5-7abc8958d0ebn%40googlegroups.com > <https://groups.google.com/d/msgid/weewx-development/baafe0ef-59d5-4de4-80e5-7abc8958d0ebn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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-development+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/CAPq0zEAKtj6WNNspDNkX6BZNsMpk8RmGjCjooV6hnn-qF_4d5A%40mail.gmail.com.