Use ruff linter to fix issues and provide consistent formatting

This commit is contained in:
Ian Renton
2026-08-15 08:25:54 +01:00
parent 7391c28cd0
commit af3f82c14d
121 changed files with 1989 additions and 996 deletions
+101 -46
View File
@@ -1,6 +1,6 @@
import os
from datetime import datetime
from threading import Thread, Event
from threading import Event, Thread
import psutil
import pytz
@@ -10,7 +10,7 @@ from core.config import SERVER_OWNER_CALLSIGN
from core.constants import SOFTWARE_VERSION
from core.data_providers import DATA_PROVIDERS
from core.data_store import DATA_STORE
from core.prometheus_metrics_handler import memory_use_gauge, spots_gauge, alerts_gauge
from core.prometheus_metrics_handler import alerts_gauge, memory_use_gauge, spots_gauge
from server.webserver import WEB_SERVER
@@ -55,55 +55,110 @@ class StatusReporter:
DATA_STORE.status_data["num_spots"] = len(DATA_STORE.spots.values())
DATA_STORE.status_data["num_alerts"] = len(DATA_STORE.alerts.values())
DATA_STORE.status_data["spot_providers"] = list(
map(lambda p: {"name": p.name, "enabled": p.enabled,
"enabled_by_default_in_web_ui": p.enabled_by_default_in_web_ui, "status": p.status,
"last_updated": p.last_update_time.replace(
tzinfo=pytz.UTC).timestamp() if p.last_update_time.year > 2000 else 0,
"last_spot": p.last_spot_time.replace(
tzinfo=pytz.UTC).timestamp() if p.last_spot_time.year > 2000 else 0},
DATA_PROVIDERS.spot_providers))
map(
lambda p: {
"name": p.name,
"enabled": p.enabled,
"enabled_by_default_in_web_ui": p.enabled_by_default_in_web_ui,
"status": p.status,
"last_updated": p.last_update_time.replace(tzinfo=pytz.UTC).timestamp()
if p.last_update_time.year > 2000
else 0,
"last_spot": p.last_spot_time.replace(tzinfo=pytz.UTC).timestamp()
if p.last_spot_time.year > 2000
else 0,
},
DATA_PROVIDERS.spot_providers,
)
)
DATA_STORE.status_data["alert_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},
DATA_PROVIDERS.alert_providers))
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,
},
DATA_PROVIDERS.alert_providers,
)
)
DATA_STORE.status_data["solar_condition_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},
DATA_PROVIDERS.solar_condition_providers))
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,
},
DATA_PROVIDERS.solar_condition_providers,
)
)
DATA_STORE.status_data["static_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},
DATA_PROVIDERS.static_data_providers))
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,
},
DATA_PROVIDERS.static_data_providers,
)
)
DATA_STORE.status_data["sig_ref_data_providers"] = list(
map(lambda p: {"sig_name": p.sig_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,
"reference_count": p.reference_count},
DATA_PROVIDERS.sig_ref_data_providers))
map(
lambda p: {
"sig_name": p.sig_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,
"reference_count": p.reference_count,
},
DATA_PROVIDERS.sig_ref_data_providers,
)
)
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,
"lookup_count": p.lookup_count},
DATA_PROVIDERS.callsign_data_providers))
DATA_STORE.status_data["cleanup"] = {"status": CLEANUP_TIMER.status,
"last_ran": CLEANUP_TIMER.last_cleanup_time.replace(
tzinfo=pytz.UTC).timestamp() if CLEANUP_TIMER.last_cleanup_time else 0}
DATA_STORE.status_data["webserver"] = {"status": WEB_SERVER.web_server_metrics["status"],
"last_api_access": WEB_SERVER.web_server_metrics[
"last_api_access_time"].replace(
tzinfo=pytz.UTC).timestamp() if WEB_SERVER.web_server_metrics[
"last_api_access_time"] else 0,
"api_access_count": WEB_SERVER.web_server_metrics["api_access_counter"],
"last_page_access": WEB_SERVER.web_server_metrics[
"last_page_access_time"].replace(
tzinfo=pytz.UTC).timestamp() if WEB_SERVER.web_server_metrics[
"last_page_access_time"] else 0,
"page_access_count": WEB_SERVER.web_server_metrics[
"page_access_counter"]}
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,
"lookup_count": p.lookup_count,
},
DATA_PROVIDERS.callsign_data_providers,
)
)
DATA_STORE.status_data["cleanup"] = {
"status": CLEANUP_TIMER.status,
"last_ran": CLEANUP_TIMER.last_cleanup_time.replace(tzinfo=pytz.UTC).timestamp()
if CLEANUP_TIMER.last_cleanup_time
else 0,
}
DATA_STORE.status_data["webserver"] = {
"status": WEB_SERVER.web_server_metrics["status"],
"last_api_access": WEB_SERVER.web_server_metrics["last_api_access_time"]
.replace(tzinfo=pytz.UTC)
.timestamp()
if WEB_SERVER.web_server_metrics["last_api_access_time"]
else 0,
"api_access_count": WEB_SERVER.web_server_metrics["api_access_counter"],
"last_page_access": WEB_SERVER.web_server_metrics["last_page_access_time"]
.replace(tzinfo=pytz.UTC)
.timestamp()
if WEB_SERVER.web_server_metrics["last_page_access_time"]
else 0,
"page_access_count": WEB_SERVER.web_server_metrics["page_access_counter"],
}
# Update Prometheus metrics
memory_use_gauge.set(psutil.Process(os.getpid()).memory_info().rss)