mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-05 18:11:41 +00:00
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
from datetime import datetime
|
|
|
|
import pytz
|
|
|
|
|
|
class CallsignDataProvider:
|
|
"""Generic callsign reference data provider class. Subclasses of this set up the various mechanisms via which
|
|
Spothole can look up data for callsigns."""
|
|
|
|
def __init__(self, name, provider_config):
|
|
"""Constructor"""
|
|
|
|
self.name = name
|
|
self.enabled = provider_config["enabled"]
|
|
self.last_update_time = datetime.min.replace(tzinfo=pytz.UTC)
|
|
self.status = "Not Started" if self.enabled else "Disabled"
|
|
|
|
def start(self):
|
|
"""Start the provider. This should return immediately after spawning threads to access remote resources, if
|
|
needed."""
|
|
|
|
raise NotImplementedError("Subclasses must implement this method")
|
|
|
|
def stop(self):
|
|
"""Stop any threads and prepare for application shutdown"""
|
|
|
|
raise NotImplementedError("Subclasses must implement this method")
|
|
|
|
def lookup(self, callsign, lookup_credentials):
|
|
"""Looks up data for the provided callsign. Takes a LookupCredentials object, which provides any credentials
|
|
that have been provided by the user for this session (QRZ.com/HamQTH) to allow us to look up using those
|
|
services on the user's behalf. (Clublog is looked up using an API key owned by the server and provided in its
|
|
config file, so users need not provide their own.) Returns a Callsign object with as much data populated as
|
|
possible."""
|
|
|
|
raise NotImplementedError("Subclasses must implement this method")
|