From 8075fb66b7caf6259cbfc25d9209110014edac5f Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Sun, 10 May 2026 19:46:26 +0800 Subject: [PATCH] =?UTF-8?q?AMOS=20=E5=A2=9E=E5=8A=A0=20info=20=E7=BA=A7?= =?UTF-8?q?=E5=88=AB=E6=97=A5=E5=BF=97=E8=BF=BD=E8=B8=AA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - weather_sources.py: _attach_korean_amos_data 记录 fetch 开始、成功/失败、温度/跑道数据 - amos_station_sources.py: _amos_get_page 记录页面匹配/不匹配 - amos_station_sources.py: fetch_amos_official_current 记录 HTML 获取和解析 - analysis_service.py: _analyze 记录 AMOS 数据是否到达分析层 重启后端后在日志中搜索 "AMOS" 可追踪完整数据流: AMOS: fetching for city=seoul AMOS page matched icao=RKSI length=... AMOS fetch_amos_official_current: got HTML for RKSI... AMOS: got data for city=seoul temp_c=... source=... AMOS _analyze: found amos data for city=seoul temp_c=... --- src/data_collection/amos_station_sources.py | 8 ++++++-- src/data_collection/weather_sources.py | 8 +++++++- web/analysis_service.py | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/data_collection/amos_station_sources.py b/src/data_collection/amos_station_sources.py index b2b6d3bc..b4862793 100644 --- a/src/data_collection/amos_station_sources.py +++ b/src/data_collection/amos_station_sources.py @@ -384,12 +384,13 @@ class AmosStationSourceMixin: return None if text and re.search(rf"\({icao}\)|\b(?:METAR|TAF)\s+{icao}\b", text, re.I): + logger.info("AMOS page matched icao={} length={}", icao, len(text)) record_source_call("amos", "page", "success", (time.perf_counter() - started) * 1000.0) return text - logger.debug("AMOS page did not expose requested airport {}", icao) + logger.warning("AMOS page did not expose requested airport {} (tried {} urls)", icao, len(urls)) return None except Exception as exc: - logger.debug("AMOS page fetch failed icao={}: {}", icao, exc) + logger.warning("AMOS page fetch failed icao={}: {}", icao, exc) record_source_call("amos", "page", "error", (time.perf_counter() - started) * 1000.0) return None @@ -419,8 +420,11 @@ class AmosStationSourceMixin: try: html = self._amos_get_page(icao) if not html: + logger.warning("AMOS fetch_amos_official_current: no HTML for {}", icao) return None + logger.info("AMOS fetch_amos_official_current: got HTML for {} ({} chars), parsing METAR/runway", icao, len(html)) + # Parse METAR line icao_pattern = re.escape(icao) metar_match = re.search(rf"METAR\s+{icao_pattern}\s.*?=", html, re.DOTALL) diff --git a/src/data_collection/weather_sources.py b/src/data_collection/weather_sources.py index c412435e..81341e7a 100644 --- a/src/data_collection/weather_sources.py +++ b/src/data_collection/weather_sources.py @@ -879,13 +879,19 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour if city_lower not in ("seoul", "busan"): return try: + logger.info("AMOS: fetching for city={}", city_lower) amos_data = self.fetch_amos_official_current( city_lower, use_fahrenheit=use_fahrenheit ) if amos_data: + logger.info("AMOS: got data for city={} temp_c={} source={} runway_pairs={}", + city_lower, amos_data.get("temp_c"), amos_data.get("temp_source"), + len(amos_data.get("runway_obs", {}).get("runway_pairs", []) or [])) results["amos"] = amos_data + else: + logger.warning("AMOS: no data returned for city={}", city_lower) except Exception as exc: - logger.debug("AMOS attach failed city={}: {}", city_lower, exc) + logger.warning("AMOS attach failed city={}: {}", city_lower, exc) def _attach_russia_official_nearby( self, results: Dict, city_lower: str, use_fahrenheit: bool diff --git a/web/analysis_service.py b/web/analysis_service.py index 0d48af17..3a71cef8 100644 --- a/web/analysis_service.py +++ b/web/analysis_service.py @@ -1733,6 +1733,9 @@ def _analyze( mg_cur = mgm.get("current", {}) if mgm else {} sc_cur = settlement_current.get("current", {}) if settlement_current else {} amos_data = raw.get("amos") or {} + if amos_data: + logger.info("AMOS _analyze: found amos data for city={} temp_c={} source={}", + city, amos_data.get("temp_c"), amos_data.get("source")) use_settlement_current = settlement_source in {"hko", "cwa", "noaa", "wunderground"} and bool(sc_cur) live_mc = mc if metar_current_is_today else {} primary_current = sc_cur if use_settlement_current else live_mc