mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-02-04 01:04:33 +00:00
WWTOTA cluster support #97
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from datetime import datetime
|
||||
|
||||
import json
|
||||
import pytz
|
||||
|
||||
from data.sig_ref import SIGRef
|
||||
@@ -17,23 +18,24 @@ class WWTOTA(HTTPSpotProvider):
|
||||
|
||||
def http_response_to_spots(self, http_response):
|
||||
new_spots = []
|
||||
response_fixed = http_response.text.replace("\\/", "/")
|
||||
response_json = json.loads(response_fixed)
|
||||
|
||||
# Iterate through source data
|
||||
for source_spot in http_response.json()["spots"]:
|
||||
print(source_spot) # todo
|
||||
for source_spot in response_json["spots"]:
|
||||
# Convert to our spot format
|
||||
# spot = Spot(source=self.name,
|
||||
# source_id=source_spot["spotId"],
|
||||
# dx_call=source_spot["activator"].upper(),
|
||||
# de_call=source_spot["spotter"].upper(),
|
||||
# freq=float(source_spot["frequency"]) * 1000,
|
||||
# mode=source_spot["mode"].upper(),
|
||||
# comment=source_spot["comments"],
|
||||
# sig="WWTOTA",
|
||||
# sig_refs=[SIGRef(id=source_spot["reference"], sig="POTA", name=source_spot["name"])],
|
||||
# time=datetime.strptime(source_spot["spotTime"], "%Y-%m-%dT%H:%M:%S").replace(
|
||||
# tzinfo=pytz.UTC).timestamp())
|
||||
#
|
||||
# # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do
|
||||
# # that for us.
|
||||
# new_spots.append(spot)
|
||||
likely_freq = float(source_spot["freq"]) * 1000
|
||||
if likely_freq < 1000000:
|
||||
likely_freq = likely_freq * 1000
|
||||
spot = Spot(source=self.name,
|
||||
dx_call=source_spot["call"].upper(),
|
||||
freq=likely_freq,
|
||||
comment=source_spot["comment"],
|
||||
sig="WWTOTA",
|
||||
sig_refs=[SIGRef(id=source_spot["ref"], sig="WWTOTA")],
|
||||
time=datetime.strptime(response_json["updated"][:10] + source_spot["time"], "%Y-%m-%d%H:%M").timestamp())
|
||||
|
||||
# Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do
|
||||
# that for us.
|
||||
new_spots.append(spot)
|
||||
return new_spots
|
||||
Reference in New Issue
Block a user