Checks daily summary version except when patching

This commit is contained in:
Tom Keffer
2017-01-10 17:38:57 -08:00
parent 928e78087c
commit f645c70604
3 changed files with 8 additions and 8 deletions

View File

@@ -15,14 +15,11 @@ import sys
import time
from datetime import datetime as dt
from distutils.version import StrictVersion
# weewx imports
import user.extensions #@UnusedImport
import weecfg
import weecfg.patch
import weedb
import weewx
import weewx.manager
import weewx.units

View File

@@ -20,7 +20,6 @@ import weedb
import weewx
from weeutil.weeutil import archiveDaySpan, genDaySpans, timestamp_to_string, startOfDay, min_with_none, tobool
from weewx import require_weewx_version
# ============================================================================
@@ -325,7 +324,8 @@ class IntervalWeighting(DatabasePatch):
if not self.dry_run:
self.dbm._set_day_summary(_day_accum,
_day_span.stop,
_cursor)
_cursor,
check_version=False)
_days += 1
# Save the ts of the patched daily summary as the
# 'lastSummaryPatched' value in the archive_day__metadata

View File

@@ -1127,8 +1127,8 @@ class DaySummaryManager(Manager):
meta_name = '%s_day__metadata' % self.table_name
self.daykeys = [x[Nprefix:] for x in all_tables if (x.startswith(prefix) and x != meta_name)]
self.version = self._getVersion()
if self.version is None:
self.version = "2.0"
if weewx.debug:
assert(self.version is not None)
def _initialize_day_tables(self, archiveSchema, cursor): # @UnusedVariable
"""Initialize the tables needed for the daily summary."""
@@ -1573,7 +1573,7 @@ class DaySummaryManager(Manager):
if not cursor:
_cursor.close()
def _set_day_summary(self, day_accum, lastUpdate, cursor):
def _set_day_summary(self, day_accum, lastUpdate, cursor, check_version=True):
"""Write all statistics for a day to the database in a single transaction.
day_accum: an accumulator with the daily summary. See weewx.accum
@@ -1582,6 +1582,9 @@ class DaySummaryManager(Manager):
Normally, this is the timestamp of the last archive record added to the instance
day_accum. """
if check_version and self.version < '2.0':
raise weewx.ViolatedPrecondition("DaySummaryManager requires >= V2.0. You have '%s'" % self.version)
# Make sure the new data uses the same unit system as the database.
self._check_unit_system(day_accum.unit_system)