mirror of
https://github.com/smittix/intercept.git
synced 2026-07-28 18:48:10 -07:00
fix: Make psycopg2 optional for Flask/Werkzeug compatibility
- Bump Flask requirement to >=3.0.0 (required for Werkzeug 3.x) - Make psycopg2 import conditional in routes/adsb.py and utils/adsb_history.py - ADS-B history features gracefully disabled when PostgreSQL libs unavailable Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -26,7 +26,7 @@ classifiers = [
|
|||||||
"Topic :: System :: Networking :: Monitoring",
|
"Topic :: System :: Networking :: Monitoring",
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flask>=2.0.0",
|
"flask>=3.0.0",
|
||||||
"skyfield>=1.45",
|
"skyfield>=1.45",
|
||||||
"pyserial>=3.5",
|
"pyserial>=3.5",
|
||||||
"Werkzeug>=3.1.5",
|
"Werkzeug>=3.1.5",
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Core dependencies
|
# Core dependencies
|
||||||
flask>=2.0.0
|
flask>=3.0.0
|
||||||
flask-limiter>=2.5.4
|
flask-limiter>=2.5.4
|
||||||
requests>=2.28.0
|
requests>=2.28.0
|
||||||
Werkzeug>=3.1.5
|
Werkzeug>=3.1.5
|
||||||
|
|||||||
+479
-470
File diff suppressed because it is too large
Load Diff
+12
-4
@@ -9,8 +9,16 @@ import time
|
|||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
import psycopg2
|
# psycopg2 is optional - only needed for PostgreSQL history persistence
|
||||||
from psycopg2.extras import execute_values, Json
|
try:
|
||||||
|
import psycopg2
|
||||||
|
from psycopg2.extras import execute_values, Json
|
||||||
|
PSYCOPG2_AVAILABLE = True
|
||||||
|
except ImportError:
|
||||||
|
psycopg2 = None # type: ignore
|
||||||
|
execute_values = None # type: ignore
|
||||||
|
Json = None # type: ignore
|
||||||
|
PSYCOPG2_AVAILABLE = False
|
||||||
|
|
||||||
from config import (
|
from config import (
|
||||||
ADSB_DB_HOST,
|
ADSB_DB_HOST,
|
||||||
@@ -199,7 +207,7 @@ class AdsbHistoryWriter:
|
|||||||
"""Background writer for ADS-B history records."""
|
"""Background writer for ADS-B history records."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.enabled = ADSB_HISTORY_ENABLED
|
self.enabled = ADSB_HISTORY_ENABLED and PSYCOPG2_AVAILABLE
|
||||||
self._queue: queue.Queue[dict] = queue.Queue(maxsize=ADSB_HISTORY_QUEUE_SIZE)
|
self._queue: queue.Queue[dict] = queue.Queue(maxsize=ADSB_HISTORY_QUEUE_SIZE)
|
||||||
self._thread: threading.Thread | None = None
|
self._thread: threading.Thread | None = None
|
||||||
self._stop_event = threading.Event()
|
self._stop_event = threading.Event()
|
||||||
@@ -297,7 +305,7 @@ class AdsbSnapshotWriter:
|
|||||||
"""Background writer for ADS-B snapshot records."""
|
"""Background writer for ADS-B snapshot records."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.enabled = ADSB_HISTORY_ENABLED
|
self.enabled = ADSB_HISTORY_ENABLED and PSYCOPG2_AVAILABLE
|
||||||
self._queue: queue.Queue[dict] = queue.Queue(maxsize=ADSB_HISTORY_QUEUE_SIZE)
|
self._queue: queue.Queue[dict] = queue.Queue(maxsize=ADSB_HISTORY_QUEUE_SIZE)
|
||||||
self._thread: threading.Thread | None = None
|
self._thread: threading.Thread | None = None
|
||||||
self._stop_event = threading.Event()
|
self._stop_event = threading.Event()
|
||||||
|
|||||||
Reference in New Issue
Block a user