mirror of
https://github.com/coulisse/spiderweb.git
synced 2024-09-21 07:27:09 +00:00
managed unparsable string on telnet
This commit is contained in:
parent
ff3cee9a0b
commit
8d3ec856e9
@ -25,4 +25,4 @@ keywords:
|
||||
- spiderweb
|
||||
license: GPL-3.0
|
||||
version: v2.5.4
|
||||
date-released: 2024-03-30
|
||||
date-released: 2024-03-31
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user