From 647bcbe67eade58e258ea77319af0cd89739ada9 Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Sun, 13 Feb 2011 15:55:33 +0000 Subject: [PATCH] Snapshot. Adding testing of generation from templates --- CHANGES.txt | 17 +++++++++++++---- bin/runreports.py | 5 ++--- bin/weeplot/genplot.py | 1 - bin/weewx/stats.py | 20 ++++++++++++++++++-- skins/Standard/index.html.tmpl | 18 ++++++++++-------- skins/Standard/month.html.tmpl | 18 ++++++++++-------- skins/Standard/week.html.tmpl | 16 +++++++++------- skins/Standard/year.html.tmpl | 10 ++++++---- 8 files changed, 68 insertions(+), 37 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8c1ece78..fd10fd2a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,20 +1,29 @@ CHANGE HISTORY -------------------------------- -1.10.0 01/17/11 +1.10.0 02/12/11 Added a weewx "favorite icon" favicon.ico that displays in your browser toolbar. Added a mobile formatted HTML page, courtesy of user Vince Skahan (thanks, Vince!!). -Added executable module "runreports.py", which will just run report generation. +Added executable module "runreports.py" for running report generation only. Y-axis plot labels (such as "°F") can now be overridden in the plot configuration section of skin.conf by using option "y_label". -Added package "user", which can contain any user extensions. This package -will not get overridden in the upgrade process. +Added package "user", which can contain any user extensions. This package will +not get overridden in the upgrade process. + +Added special tag "exists" to test whether an observation type exists. Example +$year.foo.exists will return False if there is no type "foo" in the statistical +database. + +Added special tag "has_data" to test whether an observation type exists and has +a non-zero number of data points over the aggregation period. For example, +$year.soilMoist1.has_data will return True if soilMoist1 both exists in the +stats database and contains data (meaning, you have the hardware). Now makes all of the LOOP and archive data available to services. This includes new keys: diff --git a/bin/runreports.py b/bin/runreports.py index cfb2d7fa..8cf3a869 100755 --- a/bin/runreports.py +++ b/bin/runreports.py @@ -42,10 +42,9 @@ def gen_all(config_path, gen_ts = None): socket.setdefaulttimeout(10) t = weewx.reportengine.StdReportEngine(config_path, gen_ts) - t.setDaemon(True) - t.start() - t.join() + # Although the report engine inherits from Thread, we can just run it in the main thread: + t.run() if len(sys.argv) < 2 : print "Usage: reports.py path-to-configuration-file [timestamp-to-be-generated]" diff --git a/bin/weeplot/genplot.py b/bin/weeplot/genplot.py index 90c70079..3d7ca688 100644 --- a/bin/weeplot/genplot.py +++ b/bin/weeplot/genplot.py @@ -399,7 +399,6 @@ class GeneralPlot(object): # No valid data. Pick an arbitrary scaling self.yscale=(0.0, 1.0, 0.2) else: - print ymin, ymax, self.yscale self.yscale = weeplot.utilities.scale(ymin, ymax, self.yscale) def _calcXLabelFormat(self): diff --git a/bin/weewx/stats.py b/bin/weewx/stats.py index e01fe21a..8ca684c1 100644 --- a/bin/weewx/stats.py +++ b/bin/weewx/stats.py @@ -806,8 +806,24 @@ class StatsTypeHelper(object): return weewx.units.ValueHelper.convertOnInit(self.converter, result, self.context, self.formatter) def __getattr__(self, aggregateType): - """Attribute is an aggregation type, such as 'sum', 'max', etc.""" - if self.stats_type in ('heatdeg', 'cooldeg'): + """Return statistical summary using a given aggregateType. + + aggregateType: The type of aggregation over which the summary is to be done. + This is normally something like 'sum', 'min', 'mintime', 'count', etc. + However, there are two special aggregation types that can be used to + determine the existence of data: + 'exists': Return True if the observation type exists in the database. + 'has_data': Return True if the type exists and there is a non-zero + number of entries over the aggregation period. + + returns: For special types 'exists' and 'has_data', returns a Boolean + value. Otherwise, a ValueHelper containing the aggregation data.""" + + if aggregateType == 'exists': + return self.stats_type in self.db.statsTypes + elif aggregateType == 'has_data': + return self.stats_type in self.db.statsTypes and self.db.getAggregate(self.timespan, self.stats_type, 'count')[0] != 0 + elif self.stats_type in ('heatdeg', 'cooldeg'): # Heating and cooling degree days use a different entry point into Stats: result = self.db.getHeatCool(self.timespan, self.stats_type, aggregateType, self.option_dict['heatbase'], self.option_dict['coolbase']) else: diff --git a/skins/Standard/index.html.tmpl b/skins/Standard/index.html.tmpl index c938566a..45e55430 100644 --- a/skins/Standard/index.html.tmpl +++ b/skins/Standard/index.html.tmpl @@ -79,25 +79,25 @@ Inside Temperature $current.inTemp - #if $day.extraTemp1.count.raw + #if $day.extraTemp1.has_data Pond Temperature $current.extraTemp1 #end if - #if $day.UV.count.raw + #if $day.UV.has_data UV $current.UV #end if - #if $day.ET.sum.raw > 0.0 + #if $day.ET.has_data and $day.ET.sum.raw > 0.0 ET $current.ET #end if - #if $day.radiation.count.raw + #if $day.radiation.has_data Solar Radiation $current.radiation @@ -219,7 +219,7 @@ $day.inTemp.min at $day.inTemp.mintime - #if $day.extraTemp1.count.raw + #if $day.extraTemp1.has_data High Pond Temperature
@@ -231,7 +231,7 @@ #end if - #if $day.UV.count.raw + #if $day.UV.has_data High UV
@@ -243,7 +243,7 @@ #end if - #if $day.ET.sum.raw >0.0 + #if $day.ET.has_data and $day.ET.sum.raw >0.0 High ET
@@ -255,7 +255,7 @@ #end if - #if $day.radiation.count.raw + #if $day.radiation.has_data High Radiation
@@ -334,7 +334,9 @@ Inside Wind Vector day rx percent + #if $day.extraTemp1.has_data Pond Temperatures + #end if diff --git a/skins/Standard/month.html.tmpl b/skins/Standard/month.html.tmpl index d8b10de5..0d7cacfb 100644 --- a/skins/Standard/month.html.tmpl +++ b/skins/Standard/month.html.tmpl @@ -155,7 +155,7 @@ $month.inTemp.min at $month.inTemp.mintime - #if $month.extraTemp1.count.raw + #if $month.extraTemp1.has_data High Pond Temperature
@@ -167,7 +167,7 @@ #end if - #if $month.UV.count.raw + #if $month.UV.has_data High UV
@@ -179,7 +179,7 @@ #end if - #if $month.ET.sum.raw >0.0 + #if $month.ET.has_data and $month.ET.sum.raw >0.0 High ET
@@ -191,7 +191,7 @@ #end if - #if $month.radiation.count.raw + #if $month.radiation.has_data High Radiation
@@ -334,7 +334,7 @@ $year.inTemp.min at $year.inTemp.mintime - #if $year.extraTemp1.count.raw + #if $year.extraTemp1.has_data High Pond Temperature
@@ -346,7 +346,7 @@ #end if - #if $year.UV.count.raw + #if $year.UV.has_data High UV
@@ -358,7 +358,7 @@ #end if - #if $year.ET.sum.raw >0.0 + #if $year.ET.has_data and $year.ET.sum.raw >0.0 High ET
@@ -370,7 +370,7 @@ #end if - #if $year.radiation.count.raw + #if $year.radiation.has_data High Radiation
@@ -403,7 +403,9 @@ Inside Wind Vector month rx percent + #if $month.extraTemp1.has_data Pond Temperatures + #end if diff --git a/skins/Standard/week.html.tmpl b/skins/Standard/week.html.tmpl index 682ca888..481e36b6 100644 --- a/skins/Standard/week.html.tmpl +++ b/skins/Standard/week.html.tmpl @@ -155,7 +155,7 @@ $week.inTemp.min at $week.inTemp.mintime - #if $week.extraTemp1.count.raw + #if $week.extraTemp1.has_data High Pond Temperature
@@ -167,7 +167,7 @@ #end if - #if $week.UV.count.raw + #if $week.UV.has_data High UV
@@ -179,7 +179,7 @@ #end if - #if $week.ET.sum.raw >0.0 + #if $week.ET.has_data and $week.ET.sum.raw >0.0 High ET
@@ -191,7 +191,7 @@ #end if - #if $week.radiation.count.raw + #if $week.radiation.has_data High Radiation
@@ -344,7 +344,7 @@ $month.extraTemp1.min at $month.extraTemp1.mintime - #if $month.UV.count.raw + #if $month.UV.has_data High UV
@@ -356,7 +356,7 @@ #end if - #if $month.ET.sum.raw >0.0 + #if $month.ET.has_data and $month.ET.sum.raw >0.0 High ET
@@ -368,7 +368,7 @@ #end if - #if $month.radiation.count.raw + #if $month.radiation.has_data High Radiation
@@ -401,7 +401,9 @@ Inside Wind Vector week rx percent + #if $week.extraTemp1.has_data Pond Temperatures + #end if diff --git a/skins/Standard/year.html.tmpl b/skins/Standard/year.html.tmpl index f585b949..203c85df 100644 --- a/skins/Standard/year.html.tmpl +++ b/skins/Standard/year.html.tmpl @@ -155,7 +155,7 @@ $year.inTemp.min at $year.inTemp.mintime - #if $year.extraTemp1.count.raw + #if $year.extraTemp1.has_data High Pond Temperature
@@ -167,7 +167,7 @@ #end if - #if $year.UV.count.raw + #if $year.UV.has_data High UV
@@ -179,7 +179,7 @@ #end if - #if $year.ET.sum.raw >0.0 + #if $year.ET.has_data and $year.ET.sum.raw >0.0 High ET
@@ -191,7 +191,7 @@ #end if - #if $year.radiation.count.raw + #if $year.radiation.has_data High Radiation
@@ -252,7 +252,9 @@ Inside Wind Vector year rx percent + #if $year.extraTemp1.has_data Pond Temperatures + #end if