Skip to content

Commit

Permalink
Merge pull request #44 from hmpf/fix-parse-error-in-getlog
Browse files Browse the repository at this point in the history
Fix parsing of garbage input to getlog
  • Loading branch information
hmpf authored Jan 25, 2024
2 parents 10b6a2c + d97de03 commit e00f8b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/zinolib/controllers/zino1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions src/zinolib/ritz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions src/zinolib/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import functools
import hashlib
from typing import Any


__all__ = [
Expand Down Expand Up @@ -75,7 +74,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
Expand Down

0 comments on commit e00f8b9

Please sign in to comment.