diff --git a/CITATION.cff b/CITATION.cff index 2e55c8f..cce83ef 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -25,4 +25,4 @@ keywords: - spiderweb license: GPL-3.0 version: v2.5.4 -date-released: 2024-03-30 +date-released: 2024-03-31 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a9a8208..61c6c18 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,5 @@ ### Change log -Date: 30/03/2024 +Date: 31/03/2024 Release: v2.5.4 - tested with Python 3.12 - replaced mysql driver with mariadb driver diff --git a/lib/dxtelnet.py b/lib/dxtelnet.py index 09db777..f3c55cc 100644 --- a/lib/dxtelnet.py +++ b/lib/dxtelnet.py @@ -12,6 +12,7 @@ def parse_who(lines): # create a list o lines and define the structure lines = lines.splitlines() + row_headers = ("callsign", "type", "started", "name", "average_rtt", "link") # skip first lines and last line @@ -19,7 +20,7 @@ def parse_who(lines): for i in range(3, len(lines) - 1): line = lines[i].lstrip().decode("utf-8") - logging.debug(line) + logging.debug(line) line_splitted_by_first_space = line.split(" ", 1) first_part = line_splitted_by_first_space[0] @@ -27,25 +28,29 @@ def parse_who(lines): ln = len(second_part) - if ln > 10: - fields = [first_part.encode()] #adding callsign + try: + if ln > 32: + fields = [first_part.encode()] #adding callsign - if ln > 45: - fieldstruct = struct.Struct("10s 18s 9s 2x 5s") - else: - fieldstruct = struct.Struct("10s 18s 9s") + if ln > 45: + fieldstruct = struct.Struct("10s 18s 9s 2x 5s") + else: + fieldstruct = struct.Struct("10s 18s 9s") - parse = fieldstruct.unpack_from - logging.debug(second_part) - fields += list(parse(second_part.encode())) #adding rest of informations + parse = fieldstruct.unpack_from + logging.debug(second_part) + fields += list(parse(second_part.encode())) #adding rest of informations - for j, item_field in enumerate(fields): - try: - fields[j] = item_field.decode("utf-8").strip() - except AttributeError: - logging.error(item_field) + for j, item_field in enumerate(fields): + try: + fields[j] = item_field.decode("utf-8").strip() + except AttributeError: + logging.error(item_field) - payload.append(dict(zip(row_headers, fields))) + payload.append(dict(zip(row_headers, fields))) + + except Exception as e1: + logging.error(e1) return payload