Implemented old spot cleanup thread

This commit is contained in:
Ian Renton
2025-09-27 12:09:16 +01:00
parent b1346e26ea
commit efa4c402df
8 changed files with 73 additions and 13 deletions

View File

@@ -36,12 +36,15 @@ class GMA(HTTPProvider):
sig_refs=[source_spot["REF"]],
sig_refs_names=[source_spot["NAME"]],
time=datetime.strptime(source_spot["DATE"] + source_spot["TIME"], "%Y%m%d%H%M").replace(tzinfo=pytz.UTC),
latitude=float(source_spot["LAT"]),
longitude=float(source_spot["LON"]))
latitude=float(source_spot["LAT"]) if (source_spot["LAT"] != "") else None, # Seen GMA spots with no lat/lon
longitude=float(source_spot["LON"]) if (source_spot["LON"] != "") else None)
# GMA doesn't give what programme (SIG) the reference is for until we separately look it up.
ref_info = self.REF_INFO_CACHE.get(self.REF_INFO_URL_ROOT + source_spot["REF"], headers=self.HTTP_HEADERS).json()
spot.sig = ref_info["reftype"]
ref_response = self.REF_INFO_CACHE.get(self.REF_INFO_URL_ROOT + source_spot["REF"], headers=self.HTTP_HEADERS)
# Sometimes this is blank, so handle that
if ref_response.text is not None and ref_response.text != "":
ref_info = ref_response.json()
spot.sig = ref_info["reftype"]
# Fill in any missing data
spot.infer_missing()

View File

@@ -1,8 +1,9 @@
import logging
from datetime import datetime, timezone
from datetime import datetime
from threading import Timer, Thread
from time import sleep
import pytz
import requests
from providers.provider import Provider
@@ -42,7 +43,7 @@ class HTTPProvider(Provider):
self.submit(new_spots)
self.status = "OK"
self.last_update_time = datetime.now(timezone.utc)
self.last_update_time = datetime.now(pytz.UTC)
except Exception as e:
self.status = "Error"

View File

@@ -21,13 +21,12 @@ class ParksNPeaks(HTTPProvider):
new_spots = []
# Iterate through source data
for source_spot in http_response.json():
print(source_spot)
# Convert to our spot format
spot = Spot(source=self.name(),
source_id=source_spot["actID"],
dx_call=source_spot["actCallsign"].upper(),
de_call=source_spot["actSpoter"].upper(), # typo exists in API
freq=float(source_spot["actFreq"]) * 1000,
freq=float(source_spot["actFreq"]) * 1000 if (source_spot["actFreq"] != "") else None, # Seen PNP spots with empty frequency!
mode=source_spot["actMode"].upper(),
comment=source_spot["actComments"],
sig=source_spot["actClass"],

View File

@@ -2,14 +2,14 @@ from datetime import datetime
import pytz
from core.constants import SOFTWARE_NAME, SOFTWARE_VERSION
from core.constants import SOFTWARE_NAME, SOFTWARE_VERSION, SERVER_OWNER_CALLSIGN
# Generic data provider class. Subclasses of this query the individual APIs for data.
class Provider:
# HTTP headers used for providers that use HTTP
HTTP_HEADERS = { "User-Agent": SOFTWARE_NAME + " " + SOFTWARE_VERSION }
HTTP_HEADERS = { "User-Agent": SOFTWARE_NAME + " " + SOFTWARE_VERSION + " (operated by " + SERVER_OWNER_CALLSIGN + ")" }
# Constructor
def __init__(self):