From 92592943bffc6b2dd9706ac9dc2884d6bcf43c27 Mon Sep 17 00:00:00 2001 From: Aaron Lewandowski Date: Fri, 17 May 2024 14:20:08 +0200 Subject: [PATCH] fix: except for pylint --- check_http_json.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/check_http_json.py b/check_http_json.py index c43b8d9..e242431 100755 --- a/check_http_json.py +++ b/check_http_json.py @@ -363,11 +363,15 @@ class JsonRuleProcessor: try: timestamp = datetime.fromisoformat(self.helper.get(key)) - except: - return " Value (%s) for key %s is not a Date in ISO format." % \ - (self.helper.get(key), alias) + except ValueError as ve: + return " Value (%s) for key %s is not a Date in ISO format. %s" % \ + (self.helper.get(key), alias, ve) now = datetime.now(timezone.utc) + + if timestamp.tzinfo == None: + timestamp = timestamp.replace(tzinfo=timezone.utc) + age = now - timestamp if not negative: