From 7b6642fa4b3dea9e19fca05beffab9ef97eca503 Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Thu, 12 Jan 2017 08:09:35 -0800 Subject: [PATCH] Fixed error message. Changed coding style --- bin/weecfg/patch.py | 12 +++++------- docs/devnotes.htm | 8 ++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/weecfg/patch.py b/bin/weecfg/patch.py index 206de23d..0beb5d3f 100644 --- a/bin/weecfg/patch.py +++ b/bin/weecfg/patch.py @@ -13,8 +13,6 @@ import sys import syslog import time -from datetime import datetime as dt - # weewx imports import weedb import weewx @@ -210,7 +208,7 @@ class IntervalWeighting(DatabasePatch): # after the ts of the last successfully patched daily summary _last_patched_ts = self.read_metadata('lastSummaryPatched') if _last_patched_ts: - _next_day_to_patch_dt = dt.fromtimestamp(_last_patched_ts) + datetime.timedelta(days=1) + _next_day_to_patch_dt = datetime.datetime.fromtimestamp(_last_patched_ts) + datetime.timedelta(days=1) _next_day_to_patch_ts = time.mktime(_next_day_to_patch_dt.timetuple()) else: _next_day_to_patch_ts = None @@ -285,7 +283,7 @@ class IntervalWeighting(DatabasePatch): first_ts, obs = self.first_summary() # Get the start and stop ts for our first transaction days _tr_start_ts = np_ts if np_ts is not None else first_ts - _tr_stop_dt = dt.fromtimestamp(_tr_start_ts) + datetime.timedelta(days=self.trans_days) + _tr_stop_dt = datetime.datetime.fromtimestamp(_tr_start_ts) + datetime.timedelta(days=self.trans_days) _tr_stop_ts = time.mktime(_tr_stop_dt.timetuple()) _tr_stop_ts = min(startOfDay(self.dbm.last_timestamp), _tr_stop_ts) @@ -343,9 +341,9 @@ class IntervalWeighting(DatabasePatch): break # More to process so set our start and stop for the next # transaction - _tr_start_dt = dt.fromtimestamp(_tr_stop_ts) + datetime.timedelta(days=1) + _tr_start_dt = datetime.datetime.fromtimestamp(_tr_stop_ts) + datetime.timedelta(days=1) _tr_start_ts = time.mktime(_tr_start_dt.timetuple()) - _tr_stop_dt = dt.fromtimestamp(_tr_start_ts) + datetime.timedelta(days=self.trans_days) + _tr_stop_dt = datetime.datetime.fromtimestamp(_tr_start_ts) + datetime.timedelta(days=self.trans_days) _tr_stop_ts = time.mktime(_tr_stop_dt.timetuple()) _tr_stop_ts = min(self.dbm.last_timestamp, _tr_stop_ts) @@ -364,7 +362,7 @@ class IntervalWeighting(DatabasePatch): else: # we didn't need to patch so inform the user syslog.syslog(syslog.LOG_INFO, - "intervalweighting: '%s' patch has already been applied. Patch not applied." % self.name_msg) + "intervalweighting: '%s' patch has already been applied. Patch not applied." % self.name) def genSummaryDaySpans(self, start_ts, stop_ts, obs='outTemp'): """Generator to generate a sequence of daily summary day TimeSpans. diff --git a/docs/devnotes.htm b/docs/devnotes.htm index 2647bad3..9a4d6614 100644 --- a/docs/devnotes.htm +++ b/docs/devnotes.htm @@ -258,6 +258,14 @@ next_ts = int(time.mktime(next_dt.timetuple())) extraneous "changed lines," trying to find the important stuff. + +

When invoking functions or instantiating classes, use the fully qualified name. Don't do this:

+
from datetime import dt
+now = dt()
+

Instead, do this:

+
import datetime
+now = datetime.datetime()
+

Glossary

This is a glossary of terminology used throughout the code.