mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-21 06:47:42 +00:00
Autogenerated type safety parameterisation of all methods
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from threading import Event, Thread
|
||||
from typing import Any
|
||||
|
||||
import aprslib
|
||||
import pytz
|
||||
@@ -15,17 +18,17 @@ logger = logging.getLogger(__name__)
|
||||
class APRSIS(SpotProvider):
|
||||
"""Spot provider for the APRS-IS."""
|
||||
|
||||
def __init__(self, provider_config):
|
||||
def __init__(self, provider_config: dict[str, Any]) -> None:
|
||||
super().__init__("APRS-IS", provider_config)
|
||||
self._thread = None
|
||||
self._aprsis = None
|
||||
self._stop_event = Event()
|
||||
self._thread: Thread | None = None
|
||||
self._aprsis: aprslib.IS | None = None
|
||||
self._stop_event: Event = Event()
|
||||
|
||||
def start(self):
|
||||
def start(self) -> None:
|
||||
self._thread = Thread(target=self._run, name="APRSISSpotProvider", daemon=True)
|
||||
self._thread.start()
|
||||
|
||||
def _run(self):
|
||||
def _run(self) -> None:
|
||||
while not self._stop_event.is_set():
|
||||
try:
|
||||
self._aprsis = aprslib.IS(SERVER_OWNER_CALLSIGN)
|
||||
@@ -43,7 +46,7 @@ class APRSIS(SpotProvider):
|
||||
if not self._stop_event.is_set():
|
||||
self._stop_event.wait(timeout=5)
|
||||
|
||||
def stop(self):
|
||||
def stop(self) -> None:
|
||||
self.status = "Shutting down"
|
||||
self._stop_event.set()
|
||||
if self._aprsis:
|
||||
@@ -53,7 +56,7 @@ class APRSIS(SpotProvider):
|
||||
if self._thread.is_alive():
|
||||
logger.warning("APRS-IS worker thread did not exit on time and will be killed.")
|
||||
|
||||
def _handle(self, data):
|
||||
def _handle(self, data: dict[str, Any]) -> None:
|
||||
try:
|
||||
# Split SSID in "from" call and store separately
|
||||
from_parts = str(data["from"]).split("-")
|
||||
|
||||
Reference in New Issue
Block a user