Hi

I'm trying to install the Cumulus Realtime files using this description:

realtime.txt, realtime.xml and sunbird.txt copied to the skins folder

xsearch.py copied  to the /usr/share/weewx/use folder (see attached 
xsearch.py)

My skin.conf:

[CheetahGenerator]

    search_list_extensions = user.xsearch.MyXSearch, 
user.forecast.ForecastVariables

        [[[Realtime]]]
            template=realtime.txt.tmpl

        [[[Realtime_xml]]]
            template=realtime.xml.tmpl

        [[[Sunbird]]]
            template=sunbird.txt.tmpl

After restarting weeWX, I get this error:

ul 23 17:30:16 weeWX weewx[10501]: reportengine: Caught unrecoverable 
exception in generator weewx.cheetahgenerator.CheetahGenerator
Jul 23 17:30:16 weeWX weewx[10501]:         ****  No module named stats
Jul 23 17:30:16 weeWX weewx[10501]:         ****  Traceback (most recent 
call last):
Jul 23 17:30:16 weeWX weewx[10501]:         ****    File 
"/usr/share/weewx/weewx/reportengine.py", line 239, in run
Jul 23 17:30:16 weeWX weewx[10501]:         ****      obj.start()
Jul 23 17:30:16 weeWX weewx[10501]:         ****    File 
"/usr/share/weewx/weewx/reportengine.py", line 273, in start
Jul 23 17:30:16 weeWX weewx[10501]:         ****      self.run()
Jul 23 17:30:16 weeWX weewx[10501]:         ****    File 
"/usr/share/weewx/weewx/cheetahgenerator.py", line 154, in run
Jul 23 17:30:16 weeWX weewx[10501]:         ****     
 self.initExtensions(gen_dict[section_name])
Jul 23 17:30:16 weeWX weewx[10501]:         ****    File 
"/usr/share/weewx/weewx/cheetahgenerator.py", line 196, in initExtensions
Jul 23 17:30:16 weeWX weewx[10501]:         ****      class_ = 
weeutil.weeutil._get_object(x)
Jul 23 17:30:16 weeWX weewx[10501]:         ****    File 
"/usr/share/weewx/weeutil/weeutil.py", line 1132, in _get_object
Jul 23 17:30:16 weeWX weewx[10501]:         ****      mod = 
__import__(module)
Jul 23 17:30:16 weeWX weewx[10501]:         ****    File 
"/usr/share/weewx/user/xsearch.py", line 40, in <module>
Jul 23 17:30:16 weeWX weewx[10501]:         ****      from weewx.stats 
import TimeSpanStats
Jul 23 17:30:16 weeWX weewx[10501]:         ****  ImportError: No module 
named stats
Jul 23 17:30:16 weeWX weewx[10501]:         ****  Generator terminated

I'm using weeWX version 3.7.1

Any ideas?

Thanks
Gert

-- 
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.
#
#    Copyright (c) 2009, 2010, 2013 Tom Keffer <[email protected]>
#
#    See the file LICENSE.txt for your full rights.
#
#    $Revision: 1537 $
#    $Author: mwall $
#    $Date: 2013-10-15 20:26:18 -0700 (Tue, 15 Oct 2013) $
#

"""Example of how to extend the search list used by the Cheetah generator.

This search list extension offers two extra tags:

    'alltime':   All time statistics.
                 For example, "what is the all time high temperature?"

    'seven_day': Statistics for the last seven days.
                 That is, since midnight seven days ago.

To use it, modify the option search_list in your skin.conf configuration file,
adding the name of this extension. For this example, the name of the extension
is examples.xsearch.MyXSearch. So, when you're done, it will look something
like this:

[CheetahGenerator]
    search_list_extensions = examples.xsearch.MyXSearch

Note that if your file skin.conf is from an older version of Weewx, this
section may be named [FileGenerator]. It will work just fine.

You can then use tags such as $alltime.outTemp.max for the all-time max
temperature, or $seven_day.rain.sum for the total rainfall in the last
seven days.
"""
import datetime
import time

from weewx.cheetahgenerator import SearchList
from weewx.stats import TimeSpanStats
from weeutil.weeutil import TimeSpan

class MyXSearch(SearchList):                                           # 1
    
    def __init__(self, generator):                                     # 2
        SearchList.__init__(self, generator)
  
    def get_extension(self, valid_timespan, archivedb, statsdb):       # 3
        """Returns a search list extension with two additions.
        
        Parameters:
          valid_timespan: An instance of weeutil.weeutil.TimeSpan. This will
                          hold the start and stop times of the domain of 
                          valid times.

          archivedb: An instance of weewx.archive.Archive
          
          statsdb:   An instance of weewx.stats.StatsDb
        """

        # First, get a TimeSpanStats object for all time. This one is easy
        # because the object valid_timespan already holds all valid times to be
        # used in the report.
        all_stats = TimeSpanStats(valid_timespan,
                                  statsdb,
                                  formatter=self.generator.formatter,
                                  converter=self.generator.converter)  # 4
        
        # Now get a TimeSpanStats object for the last seven days. This one we
        # will have to calculate. First, calculate the time at midnight, seven
        # days ago. The variable week_dt will be an instance of datetime.date.
        week_dt = datetime.date.fromtimestamp(valid_timespan.stop) - datetime.timedelta(weeks=1)    # 5
        # Now convert it to unix epoch time:
        week_ts = time.mktime(week_dt.timetuple())                     # 6
        # Now form a TimeSpanStats object, using the time span we just
        # calculated:
        seven_day_stats = TimeSpanStats(TimeSpan(week_ts, valid_timespan.stop),
                                        statsdb,
                                        formatter=self.generator.formatter,
                                        converter=self.generator.converter) # 7

        yesterday_dt = datetime.date.fromtimestamp(valid_timespan.stop) - datetime.timedelta(days=1) #8
        yesterday_ts = time.mktime(yesterday_dt.timetuple())  #9
        yesterday_stats = TimeSpanStats(TimeSpan(yesterday_ts, yesterday_ts + (24 * 3600)), 
                                        statsdb,
                                        formatter=self.generator.formatter,
                                        converter=self.generator.converter) #10
       
        # Now create a small dictionary with keys 'alltime' and 'seven_day' and 'yesterday':
        search_list_extension = {'alltime'   : all_stats,
                                 'yesterday' : yesterday_stats,
                                 'seven_day' : seven_day_stats}             #11
        
        return search_list_extension

Reply via email to