From 386c0ecff75e1a7feffb777a95630afd821f1f4d Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Thu, 25 Jan 2024 08:05:03 +0100 Subject: [PATCH 1/3] Log exception correctly --- src/zinolib/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zinolib/utils.py b/src/zinolib/utils.py index dca5819..0e4bc87 100644 --- a/src/zinolib/utils.py +++ b/src/zinolib/utils.py @@ -75,7 +75,7 @@ def wrapper(*args, **kwargs): except Exception as e: params = f'args={args} kwargs={kwargs}' funcname = function.__name__ - logger.exception(f'"{funcname}" failed with: {params}\n{e}') + logger.exception('"%s" failed with: %s\n%s', funcname, params, e) if reraise: raise return return_value From ebff3756b0323fae6a2510084bd6f00dd6636699 Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Thu, 25 Jan 2024 08:06:23 +0100 Subject: [PATCH 2/3] Handle flawed input to zino log parser --- src/zinolib/controllers/zino1.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/zinolib/controllers/zino1.py b/src/zinolib/controllers/zino1.py index 8dbfa2d..1257ff0 100644 --- a/src/zinolib/controllers/zino1.py +++ b/src/zinolib/controllers/zino1.py @@ -397,7 +397,11 @@ def parse_response(log_data: Iterable[str]) -> list[LogDict]: log_list: List[LogDict] = [] for row in log_data: timestamp, log = row.split(" ", 1) - dt = convert_timestamp(int(timestamp)) + try: + timestamp = int(timestamp) + except ValueError as e: + raise RetryError('Zino 1 is flaking out, retry') from e + dt = convert_timestamp(timestamp) log_list.append({"date": dt, "log": log}) return log_list From d97de0369fc593f0767b6df01c9a6f9664dbaa96 Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Thu, 25 Jan 2024 08:50:24 +0100 Subject: [PATCH 3/3] Mollify flake8 --- src/zinolib/ritz.py | 6 ++++-- src/zinolib/utils.py | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/zinolib/ritz.py b/src/zinolib/ritz.py index c817d93..1352d84 100644 --- a/src/zinolib/ritz.py +++ b/src/zinolib/ritz.py @@ -86,7 +86,7 @@ import codecs import select -from .config.tcl import parse_tcl_config +from .config.tcl import parse_tcl_config # noqa: F401 (used to be in this file) from .utils import windows_codepage_cp1252, generate_authtoken @@ -260,7 +260,9 @@ def __getattr__(self, name): return self.get_downtime() else: self.__getattribute__(name) - # raise AttributeError("%s instance of type %s has no attribute '%s'" % (self.__class__, self._attrs["type"], name)) + # raise AttributeError( + # "%s instance of type %s has no attribute '%s'" % (self.__class__, self._attrs["type"], name) + # ) return self def __getitem__(self, key): diff --git a/src/zinolib/utils.py b/src/zinolib/utils.py index 0e4bc87..7c07f21 100644 --- a/src/zinolib/utils.py +++ b/src/zinolib/utils.py @@ -1,6 +1,5 @@ import functools import hashlib -from typing import Any __all__ = [