From c16f924652ceba2fe4c75b2f776defc51f46f235 Mon Sep 17 00:00:00 2001 From: Jereme Haack Date: Wed, 28 Oct 2015 09:15:29 -0700 Subject: [PATCH] Address #174: dbapi2 parsing bug. --- services/core/SQLHistorian/setup.py | 2 +- volttron/platform/agent/utils.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/services/core/SQLHistorian/setup.py b/services/core/SQLHistorian/setup.py index eed95cc899..4dfb2efb90 100644 --- a/services/core/SQLHistorian/setup.py +++ b/services/core/SQLHistorian/setup.py @@ -63,7 +63,7 @@ setup( name = package + 'agent', - version = "3.0", + version = "3.0.1", install_requires = ['volttron', 'ply'], packages = packages, entry_points = { diff --git a/volttron/platform/agent/utils.py b/volttron/platform/agent/utils.py index 1b2f1f6ebe..8c8bc7cf23 100644 --- a/volttron/platform/agent/utils.py +++ b/volttron/platform/agent/utils.py @@ -59,6 +59,7 @@ import argparse from dateutil.parser import parse +from datetime import timedelta import logging import os import pytz @@ -85,6 +86,8 @@ re.MULTILINE | re.DOTALL) +_log = logging.getLogger(__name__) + def _repl(match): '''Replace the matched group with an appropriate string.''' # If the first group matched, a quoted string was matched and should @@ -282,6 +285,11 @@ def process_timestamp(timestamp_string): try: timestamp = parse(timestamp_string) + + #The following addresses #174: error with dbapi2 + if not timestamp.microsecond: + _log.warn("No microsecond in timestamp. Adding 1 to prevent dbapi2 bug.") + timestamp = timestamp + timedelta(microseconds = 1) except (ValueError, TypeError) as e: _log.error("message for {topic} bad timetamp string: {ts_string}".format(topic=topic, ts_string=timestamp_string))