mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 02:21:42 +00:00
Refactor of caching & data storage part 16 #118
This commit is contained in:
+10
-9
@@ -29,15 +29,7 @@ class DataProviders:
|
||||
|
||||
|
||||
def start(self):
|
||||
for p in self.spot_providers:
|
||||
if p.enabled:
|
||||
p.start()
|
||||
for p in self.alert_providers:
|
||||
if p.enabled:
|
||||
p.start()
|
||||
for p in self.solar_condition_providers:
|
||||
if p.enabled:
|
||||
p.start()
|
||||
# Start data providers before spot/alert providers so the lookup data is there already for incoming spots
|
||||
for p in self.static_data_providers:
|
||||
if p.enabled:
|
||||
p.start()
|
||||
@@ -47,6 +39,15 @@ class DataProviders:
|
||||
for p in self.callsign_data_providers:
|
||||
if p.enabled:
|
||||
p.start()
|
||||
for p in self.spot_providers:
|
||||
if p.enabled:
|
||||
p.start()
|
||||
for p in self.alert_providers:
|
||||
if p.enabled:
|
||||
p.start()
|
||||
for p in self.solar_condition_providers:
|
||||
if p.enabled:
|
||||
p.start()
|
||||
|
||||
def stop(self):
|
||||
for sp in self.spot_providers:
|
||||
|
||||
@@ -84,7 +84,8 @@ class StatusReporter:
|
||||
DATA_STORE.status_data["callsign_data_providers"] = list(
|
||||
map(lambda p: {"name": p.name, "enabled": p.enabled, "status": p.status,
|
||||
"last_updated": p.last_update_time.replace(
|
||||
tzinfo=pytz.UTC).timestamp() if p.last_update_time.year > 2000 else 0},
|
||||
tzinfo=pytz.UTC).timestamp() if p.last_update_time.year > 2000 else 0,
|
||||
"lookup_count": p.lookup_count},
|
||||
DATA_PROVIDERS.callsign_data_providers))
|
||||
DATA_STORE.status_data["webserver"] = {"status": WEB_SERVER.web_server_metrics["status"],
|
||||
"last_api_access": WEB_SERVER.web_server_metrics[
|
||||
|
||||
+6
-1
@@ -2,6 +2,7 @@ import logging
|
||||
|
||||
import simplejson
|
||||
from pyhamtools.frequency import freq_to_band
|
||||
from pyhamtools.locator import latlong_to_locator
|
||||
|
||||
from core.constants import UNKNOWN_BAND, BANDS, CW_MODES, PHONE_MODES, DATA_MODES, MODE_ALIASES, ALL_MODES
|
||||
from core.data_store import DATA_STORE
|
||||
@@ -95,6 +96,9 @@ def get_callsign_object_from_pyhamtools_callinfo(callsign, callinfo):
|
||||
itu_zone = data["ituz"] if "ituz" in data else None
|
||||
lat = float(data["latitude"]) if "latitude" in data else None
|
||||
lon = float(data["longitude"]) if "longitude" in data else None
|
||||
grid = None
|
||||
if lat and lon:
|
||||
grid = latlong_to_locator(lat, lon)
|
||||
|
||||
return Callsign(call=callsign,
|
||||
home_call=home_call,
|
||||
@@ -105,8 +109,9 @@ def get_callsign_object_from_pyhamtools_callinfo(callsign, callinfo):
|
||||
itu_zone=itu_zone,
|
||||
latitude=lat,
|
||||
longitude=lon,
|
||||
grid=grid,
|
||||
location_source="DXCC")
|
||||
|
||||
except ValueError:
|
||||
except (KeyError, ValueError):
|
||||
# Unknown callsign, can't look anything up, return a Callsign object with basic data so that gets cached
|
||||
return Callsign(call=callsign)
|
||||
|
||||
Reference in New Issue
Block a user