From 045a62e05c749f2b574a57027b2ee5dd42900040 Mon Sep 17 00:00:00 2001 From: Tomas Tomecek Date: Sat, 18 Mar 2017 22:34:22 +0100 Subject: [PATCH] improve datetime parsing make it less error-prone, b/c apparently docker is able to return really wild values: ValueError: unconverted data remains: Z Signed-off-by: Tomas Tomecek --- sen/docker_backend.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sen/docker_backend.py b/sen/docker_backend.py index 2f5260b..4ab77ee 100644 --- a/sen/docker_backend.py +++ b/sen/docker_backend.py @@ -607,7 +607,12 @@ def started_at(self): s = s[:26] if s == "0001-01-01T00:00:00Z": return DINOSAUR_TIME - started_at = datetime.datetime.strptime(s, ISO_DATETIME_PARSE_STRING) + s = s.replace("Z", "0") + try: + started_at = datetime.datetime.strptime(s, ISO_DATETIME_PARSE_STRING) + except ValueError as ex: + logger.error("unable to parse datetime %s: %s", s, ex) + return DINOSAUR_TIME return started_at @property