mirror of
https://github.com/weewx/weewx.git
synced 2026-04-18 16:46:56 -04:00
Checks daily summary version except when patching
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user