|
@@ -1028,14 +1028,14 @@ class NewsAnalyzer:
|
|
|
|
|
|
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
- def _initialize_and_check_config(self) -> None:
|
|
|
|
|
- """通用初始化和配置检查"""
|
|
|
|
|
|
|
+ def _initialize_and_check_config(self) -> bool:
|
|
|
|
|
+ """通用初始化和配置检查。返回 True 表示可以继续执行。"""
|
|
|
now = self.ctx.get_time()
|
|
now = self.ctx.get_time()
|
|
|
print(f"当前北京时间: {now.strftime('%Y-%m-%d %H:%M:%S')}")
|
|
print(f"当前北京时间: {now.strftime('%Y-%m-%d %H:%M:%S')}")
|
|
|
|
|
|
|
|
if not self.ctx.config["ENABLE_CRAWLER"]:
|
|
if not self.ctx.config["ENABLE_CRAWLER"]:
|
|
|
print("爬虫功能已禁用(ENABLE_CRAWLER=False),程序退出")
|
|
print("爬虫功能已禁用(ENABLE_CRAWLER=False),程序退出")
|
|
|
- return
|
|
|
|
|
|
|
+ return False
|
|
|
|
|
|
|
|
has_notification = self._has_notification_configured()
|
|
has_notification = self._has_notification_configured()
|
|
|
if not self.ctx.config["ENABLE_NOTIFICATION"]:
|
|
if not self.ctx.config["ENABLE_NOTIFICATION"]:
|
|
@@ -1048,6 +1048,7 @@ class NewsAnalyzer:
|
|
|
mode_strategy = self._get_mode_strategy()
|
|
mode_strategy = self._get_mode_strategy()
|
|
|
print(f"报告模式: {self.report_mode}")
|
|
print(f"报告模式: {self.report_mode}")
|
|
|
print(f"运行模式: {mode_strategy['description']}")
|
|
print(f"运行模式: {mode_strategy['description']}")
|
|
|
|
|
+ return True
|
|
|
|
|
|
|
|
def _crawl_data(self) -> Tuple[Dict, Dict, List]:
|
|
def _crawl_data(self) -> Tuple[Dict, Dict, List]:
|
|
|
"""执行数据爬取"""
|
|
"""执行数据爬取"""
|
|
@@ -1706,7 +1707,8 @@ class NewsAnalyzer:
|
|
|
def run(self) -> None:
|
|
def run(self) -> None:
|
|
|
"""执行分析流程"""
|
|
"""执行分析流程"""
|
|
|
try:
|
|
try:
|
|
|
- self._initialize_and_check_config()
|
|
|
|
|
|
|
+ if not self._initialize_and_check_config():
|
|
|
|
|
+ return
|
|
|
|
|
|
|
|
mode_strategy = self._get_mode_strategy()
|
|
mode_strategy = self._get_mode_strategy()
|
|
|
|
|
|