filter out problematic spots instead of breaking completely

This commit is contained in:
Jakob Ketterl 2020-12-09 23:38:27 +01:00
parent eef61f9d1e
commit fcff9d16ff

View File

@ -115,6 +115,8 @@ class Uploader(object):
def getPackets(self, spots):
encoded = [self.encodeSpot(spot) for spot in spots]
# filter out any erroneous encodes
encoded = [e for e in encoded if e is not None]
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
@ -150,6 +152,7 @@ class Uploader(object):
return [len(s)] + list(s.encode("utf-8"))
def encodeSpot(self, spot):
try:
return bytes(
self.encodeString(spot["callsign"])
+ list(int(spot["freq"]).to_bytes(4, "big"))
@ -160,6 +163,9 @@ class Uploader(object):
+ [0x01]
+ list(int(spot["timestamp"] / 1000).to_bytes(4, "big"))
)
except Exception:
logger.exception("Error while encoding spot for pskreporter")
return None
def getReceiverInformationHeader(self):
return bytes(