fixed regex for extracting time

changed decode of telnet stream to utf-8
This commit is contained in:
Michael Clemens 2022-05-22 21:27:39 +02:00
parent 8fb104240a
commit eaad4e569b
3 changed files with 7 additions and 5 deletions

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = colorspot name = colorspot
version = 0.1.5 version = 0.1.6
author = Michael Clemens author = Michael Clemens
author_email = colorspot@qrz.is author_email = colorspot@qrz.is
description = A colorful CLI DX cluster client with LotW integration description = A colorful CLI DX cluster client with LotW integration

View File

@ -1,3 +1,3 @@
from colorspot.__main__ import ColorSpot from colorspot.__main__ import ColorSpot
__version__ = '0.1.5' __version__ = '0.1.6'

View File

@ -268,7 +268,8 @@ class ColorSpot():
while True: while True:
line_enc = telnet.read_until(b"\n") # Read one line line_enc = telnet.read_until(b"\n") # Read one line
try: try:
line = line_enc.decode('ascii') #line = line_enc.decode('ascii')
line = line_enc.decode('utf-8')
except: except:
print("Error while encoding the following line:") print("Error while encoding the following line:")
print(line_enc) print(line_enc)
@ -298,7 +299,8 @@ class ColorSpot():
call_de = re.search('D(X|x) de (.+?): ', line).group(2) call_de = re.search('D(X|x) de (.+?): ', line).group(2)
freq = re.search(': +(.+?) ', line).group(1) freq = re.search(': +(.+?) ', line).group(1)
call_dx = re.search(freq + ' +(.+?) ', line).group(1) call_dx = re.search(freq + ' +(.+?) ', line).group(1)
time = re.search('[^ ]*$', line).group(0)[0:4] #time = re.search('[^ ]*$', line).group(0)[0:4]
time = re.search(' (\d{4})Z', line).group(1)
comment = re.search(call_dx + ' +(.+?) +' + time, line).group(1) comment = re.search(call_dx + ' +(.+?) +' + time, line).group(1)
# If the CTY file is available, further information will be # If the CTY file is available, further information will be
@ -317,7 +319,7 @@ class ColorSpot():
if self.check_lotw_activity and self.check_lotw(call_dx): if self.check_lotw_activity and self.check_lotw(call_dx):
lotw = "" lotw = ""
else: else:
lotw = "" lotw = " "
# Depending on the user's choice, the row will be color coded # Depending on the user's choice, the row will be color coded
# depending on the band or the DX station's continent # depending on the band or the DX station's continent