first commit
This commit is contained in:
32
collector/config.py
Normal file
32
collector/config.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Config:
|
||||
db_url: str
|
||||
api_key: str
|
||||
station_call: str
|
||||
aprs_is_host: str
|
||||
aprs_is_port: int
|
||||
aprs_is_callsign: str
|
||||
aprs_is_passcode: str
|
||||
aprs_is_filter: str
|
||||
log_level: str
|
||||
|
||||
@classmethod
|
||||
def from_env(cls) -> "Config":
|
||||
api_key = os.environ.get("API_KEY", "")
|
||||
if not api_key:
|
||||
raise RuntimeError("API_KEY environment variable is required")
|
||||
return cls(
|
||||
db_url=os.getenv("DATABASE_URL", "postgresql://aprs:aprs@db:5432/aprs"),
|
||||
api_key=api_key,
|
||||
station_call=os.getenv("STATION_CALL", "SA6ANW-1"),
|
||||
aprs_is_host=os.getenv("APRS_IS_HOST", "rotate.aprs2.net"),
|
||||
aprs_is_port=int(os.getenv("APRS_IS_PORT", "14580")),
|
||||
aprs_is_callsign=os.getenv("APRS_IS_CALLSIGN", "SA6ANW-1"),
|
||||
aprs_is_passcode=os.getenv("APRS_IS_PASSCODE", "-1"),
|
||||
aprs_is_filter=os.getenv("APRS_IS_FILTER", "r/58.35/14.05/200"),
|
||||
log_level=os.getenv("LOG_LEVEL", "INFO"),
|
||||
)
|
||||
Reference in New Issue
Block a user