mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Giant refactor to rebrand "SIG" as "Activity" anywhere that doesn't touch API or config file (which is to be addressed in a future breaking change). #147
This commit is contained in:
@@ -4,8 +4,8 @@ import pytz
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from core.enums import AlertType
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.alert import Alert
|
||||
from data.sig_ref import SIGRef
|
||||
from providers.alert.http_alert_provider import HTTPAlertProvider
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class BOTA(HTTPAlertProvider):
|
||||
alert = Alert(
|
||||
source=self.name,
|
||||
dx_calls=[dx_call],
|
||||
sig_refs=[SIGRef(id=ref_name, sig="BOTA")],
|
||||
sig_refs=[ActivityRef(id=ref_name, sig="BOTA")],
|
||||
start_time=date_time.timestamp(),
|
||||
alert_type=AlertType.XOTA,
|
||||
)
|
||||
|
||||
@@ -3,8 +3,8 @@ from datetime import datetime
|
||||
import pytz
|
||||
|
||||
from core.enums import AlertType
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.alert import Alert
|
||||
from data.sig_ref import SIGRef
|
||||
from providers.alert.http_alert_provider import HTTPAlertProvider
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ class Hamsat(HTTPAlertProvider):
|
||||
dx_calls=[source_alert["callsign"].upper()],
|
||||
freqs_modes=freqs_modes,
|
||||
comment=source_alert["comment"],
|
||||
# Fudge a SIG ref to provide the remaining bits of data we need: the satellite and the operator's grid
|
||||
# Fudge an activity ref to provide the remaining bits of data we need: the satellite and the operator's grid
|
||||
sig_refs=[
|
||||
SIGRef(
|
||||
ActivityRef(
|
||||
sig="AMSAT",
|
||||
id=f"{source_alert['satellite']['name']} from {source_alert['grids'][0]}",
|
||||
)
|
||||
|
||||
@@ -4,8 +4,8 @@ from datetime import datetime
|
||||
import pytz
|
||||
|
||||
from core.enums import AlertType
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.alert import Alert
|
||||
from data.sig_ref import SIGRef
|
||||
from providers.alert.http_alert_provider import HTTPAlertProvider
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -25,23 +25,23 @@ class ParksNPeaks(HTTPAlertProvider):
|
||||
# Iterate through source data
|
||||
for source_alert in http_response.json():
|
||||
# Calculate some things
|
||||
sig = source_alert["Class"].upper()
|
||||
activity = source_alert["Class"].upper()
|
||||
if " - " in source_alert["Location"]:
|
||||
split = source_alert["Location"].split(" - ")
|
||||
sig_ref = split[0]
|
||||
sig_ref_name = split[1]
|
||||
ref_id = split[0]
|
||||
ref_name = split[1]
|
||||
else:
|
||||
sig_ref = source_alert["WWFFID"]
|
||||
sig_ref_name = source_alert["Location"]
|
||||
ref_id = source_alert["WWFFID"]
|
||||
ref_name = source_alert["Location"]
|
||||
start_time = (
|
||||
datetime.strptime(source_alert["alTime"], "%Y-%m-%d %H:%M:%S").replace(tzinfo=pytz.UTC).timestamp()
|
||||
)
|
||||
|
||||
sigrefs = []
|
||||
# PnP can give us an alert of class "QRP" which is the only one that's not a real SIG in Spothole's list,
|
||||
# so mask this out if we got it.
|
||||
if sig != "QRP":
|
||||
sigrefs = [SIGRef(id=sig_ref, sig=sig, name=sig_ref_name)]
|
||||
activity_refs = []
|
||||
# PnP can give us an alert of class "QRP" which is the only one that's not a real activity in Spothole's
|
||||
# list, so mask this out if we got it.
|
||||
if activity != "QRP":
|
||||
activity_refs = [ActivityRef(id=ref_id, sig=activity, name=ref_name)]
|
||||
|
||||
# Convert to our alert format
|
||||
alert = Alert(
|
||||
@@ -50,13 +50,13 @@ class ParksNPeaks(HTTPAlertProvider):
|
||||
dx_calls=[source_alert["CallSign"].upper()],
|
||||
freqs_modes=f"{source_alert['Freq']} {source_alert['MODE']}",
|
||||
comment=source_alert["Comments"],
|
||||
sig_refs=sigrefs,
|
||||
sig_refs=activity_refs,
|
||||
start_time=start_time,
|
||||
alert_type=AlertType.XOTA,
|
||||
)
|
||||
|
||||
# Log a warning for the developer if PnP gives us an unknown programme we've never seen before
|
||||
if sig and sig not in [
|
||||
if activity and activity not in [
|
||||
"POTA",
|
||||
"SOTA",
|
||||
"WWFF",
|
||||
@@ -68,11 +68,11 @@ class ParksNPeaks(HTTPAlertProvider):
|
||||
"LLOTA",
|
||||
"QRP",
|
||||
]:
|
||||
logger.warning(f"PNP alert found with sig {sig}, developer needs to add support for this!")
|
||||
logger.warning(f"PNP alert found with activity {activity}, developer needs to add support for this!")
|
||||
|
||||
# If this is POTA, SOTA or WWFF data we already have it through other means, so ignore. Otherwise, add to
|
||||
# the alert list. Note that while ZLOTA has its own spots API, it doesn't have its own alerts API. So that
|
||||
# means the PnP *spot* provider rejects ZLOTA spots here, but the PnP *alerts* provider here allows ZLOTA.
|
||||
if sig not in ["POTA", "SOTA", "WWFF"]:
|
||||
if activity not in ["POTA", "SOTA", "WWFF"]:
|
||||
new_alerts.append(alert)
|
||||
return new_alerts
|
||||
|
||||
@@ -3,8 +3,8 @@ from datetime import datetime
|
||||
import pytz
|
||||
|
||||
from core.enums import AlertType
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.alert import Alert
|
||||
from data.sig_ref import SIGRef
|
||||
from providers.alert.http_alert_provider import HTTPAlertProvider
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class POTA(HTTPAlertProvider):
|
||||
freqs_modes=source_alert["frequencies"],
|
||||
comment=source_alert["comments"],
|
||||
sig_refs=[
|
||||
SIGRef(
|
||||
ActivityRef(
|
||||
id=source_alert["reference"],
|
||||
sig="POTA",
|
||||
name=source_alert["name"],
|
||||
|
||||
@@ -3,8 +3,8 @@ from datetime import datetime
|
||||
import pytz
|
||||
|
||||
from core.enums import AlertType
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.alert import Alert
|
||||
from data.sig_ref import SIGRef
|
||||
from providers.alert.http_alert_provider import HTTPAlertProvider
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class SOTA(HTTPAlertProvider):
|
||||
freqs_modes=source_alert["frequency"],
|
||||
comment=source_alert["comments"],
|
||||
sig_refs=[
|
||||
SIGRef(
|
||||
ActivityRef(
|
||||
id=f"{source_alert['associationCode']}/{source_alert['summitCode']}",
|
||||
sig="SOTA",
|
||||
name=summit_name,
|
||||
|
||||
@@ -7,8 +7,8 @@ import pytz
|
||||
from rss_parser import Parser as RSSParser
|
||||
from rss_parser.models.rss import RSS
|
||||
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.alert import Alert
|
||||
from data.sig_ref import SIGRef
|
||||
from providers.alert.http_alert_provider import HTTPAlertProvider
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -74,7 +74,7 @@ class WOTA(HTTPAlertProvider):
|
||||
dx_calls=[dx_call],
|
||||
freqs_modes=freqs_modes,
|
||||
comment=comment,
|
||||
sig_refs=[SIGRef(id=ref, sig="WOTA", name=ref_name)] if ref else [],
|
||||
sig_refs=[ActivityRef(id=ref, sig="WOTA", name=ref_name)] if ref else [],
|
||||
start_time=time.timestamp(),
|
||||
)
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ from datetime import datetime
|
||||
import pytz
|
||||
|
||||
from core.enums import AlertType
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.alert import Alert
|
||||
from data.sig_ref import SIGRef
|
||||
from providers.alert.http_alert_provider import HTTPAlertProvider
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class WWFF(HTTPAlertProvider):
|
||||
dx_calls=[source_alert["activator_call"].upper()],
|
||||
freqs_modes=f"{source_alert['band']} {source_alert['mode']}",
|
||||
comment=source_alert["remarks"],
|
||||
sig_refs=[SIGRef(id=source_alert["reference"], sig="WWFF")],
|
||||
sig_refs=[ActivityRef(id=source_alert["reference"], sig="WWFF")],
|
||||
start_time=datetime.strptime(source_alert["utc_start"], "%Y-%m-%d %H:%M:%S")
|
||||
.replace(tzinfo=pytz.UTC)
|
||||
.timestamp(),
|
||||
|
||||
Reference in New Issue
Block a user