Backup automatico script del 2026-01-25 07:00
This commit is contained in:
@@ -19,6 +19,7 @@ from zoneinfo import ZoneInfo
|
||||
|
||||
import requests
|
||||
from dateutil import parser
|
||||
from open_meteo_client import open_meteo_get
|
||||
|
||||
# =============================================================================
|
||||
# CONFIGURATION
|
||||
@@ -278,7 +279,7 @@ def fetch_soil_and_weather(lat: float, lon: float, timezone: str = TZ) -> Option
|
||||
}
|
||||
|
||||
try:
|
||||
r = requests.get(OPEN_METEO_URL, params=params, headers=HTTP_HEADERS, timeout=30)
|
||||
r = open_meteo_get(OPEN_METEO_URL, params=params, headers=HTTP_HEADERS, timeout=(5, 30))
|
||||
if r.status_code == 400:
|
||||
try:
|
||||
j = r.json()
|
||||
@@ -331,7 +332,7 @@ def fetch_weather_only(lat: float, lon: float, timezone: str = TZ) -> Optional[D
|
||||
}
|
||||
|
||||
try:
|
||||
r = requests.get(OPEN_METEO_URL, params=params, headers=HTTP_HEADERS, timeout=30)
|
||||
r = open_meteo_get(OPEN_METEO_URL, params=params, headers=HTTP_HEADERS, timeout=(5, 30))
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
except Exception as e:
|
||||
@@ -1495,6 +1496,12 @@ def main():
|
||||
lon = args.lon if args.lon is not None else DEFAULT_LON
|
||||
location = args.location if args.location else DEFAULT_LOCATION_NAME
|
||||
timezone = args.timezone if args.timezone else TZ
|
||||
|
||||
run_mode = "auto" if args.auto else "manual"
|
||||
LOGGER.info("Heartbeat: start mode=%s location=%s", run_mode, location)
|
||||
if args.auto:
|
||||
now_str = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
print(f"{now_str} INFO Heartbeat auto run for {location}")
|
||||
|
||||
# Determina modalità operativa
|
||||
force_send = args.force or args.debug
|
||||
|
||||
Reference in New Issue
Block a user