setting avg time on telnet

This commit is contained in:
coulisse 2024-03-30 07:38:37 +01:00
parent 2027ec9da8
commit ff3cee9a0b

View File

@ -9,32 +9,34 @@ import logging
def parse_who(lines):
# print(lines.decode('ascii'))
# create a list o lines and define the structure
lines = lines.splitlines()
#fmtstring = "2x 9s 10s 18s 9s 8s 15s"
#fmtstring = "10s 18s 9s 8s 15s"
fmtstring = "10s 18s 9s"
fieldstruct = struct.Struct(fmtstring)
row_headers = ("callsign", "type", "started", "name", "average_rtt", "link")
# skip first lines and last line
payload = []
for i in range(3, len(lines) - 1):
#line = lines[i]
line = lines[i].lstrip().decode("utf-8")
logging.debug(line)
line_splitted_by_first_space = line.split(" ", 1)
first_part = line_splitted_by_first_space[0]
second_part = line_splitted_by_first_space[1]
ln = len(second_part)
if ln > 10:
fields = [first_part.encode()] #adding callsign
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
for j, item_field in enumerate(fields):