添加config str函数
This commit is contained in:
@@ -65,9 +65,12 @@ class AppConfig:
|
|||||||
|
|
||||||
# 浏览器配置
|
# 浏览器配置
|
||||||
headless: bool = os.getenv("HEADLESS", "true").lower() == "true"
|
headless: bool = os.getenv("HEADLESS", "true").lower() == "true"
|
||||||
headless = False
|
|
||||||
default_timeout: float = float(os.getenv("DEFAULT_TIMEOUT", "6000000"))
|
default_timeout: float = float(os.getenv("DEFAULT_TIMEOUT", "6000000"))
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
# 返回邮箱和数据表名的信息
|
||||||
|
return f"AppConfig(email_account={self.email_account}, table_name={self.table_name})"
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
"""初始化后处理"""
|
"""初始化后处理"""
|
||||||
self.mysql_config = MysqlConfig.parse_file(self.config_file_path)
|
self.mysql_config = MysqlConfig.parse_file(self.config_file_path)
|
||||||
@@ -431,6 +434,7 @@ class TaskScheduler:
|
|||||||
|
|
||||||
def upload_bets_task(self, date_str: Optional[str] = None) -> None:
|
def upload_bets_task(self, date_str: Optional[str] = None) -> None:
|
||||||
"""上传投注数据任务"""
|
"""上传投注数据任务"""
|
||||||
|
config_base_info = str(self.config)
|
||||||
try:
|
try:
|
||||||
if date_str is None:
|
if date_str is None:
|
||||||
date_str = (
|
date_str = (
|
||||||
@@ -450,17 +454,20 @@ class TaskScheduler:
|
|||||||
self.oddsjam_service.upload_bets(self.config.bet_file_path)
|
self.oddsjam_service.upload_bets(self.config.bet_file_path)
|
||||||
|
|
||||||
# 发送通知
|
# 发送通知
|
||||||
self.config.dingtalk.send_text(f"{date_str}: \n {data_info}")
|
self.config.dingtalk.send_text(
|
||||||
|
f"{date_str}: \n {config_base_info} \n {data_info}"
|
||||||
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_info = traceback.format_exc()
|
error_info = traceback.format_exc()
|
||||||
logger.error(f"上传任务失败: {error_info}")
|
logger.error(f"上传任务失败: {error_info}")
|
||||||
self.config.dingtalk.send_text(
|
self.config.dingtalk.send_text(
|
||||||
f"{date_str}: 上传比赛失败: {e}\n{error_info}"
|
f"{date_str}: \n {config_base_info} \n 上传比赛失败: {e}\n{error_info}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def pull_status_task(self, date_str: Optional[str] = None) -> None:
|
def pull_status_task(self, date_str: Optional[str] = None) -> None:
|
||||||
"""拉取状态数据任务"""
|
"""拉取状态数据任务"""
|
||||||
|
config_base_info = str(self.config)
|
||||||
try:
|
try:
|
||||||
if date_str is None:
|
if date_str is None:
|
||||||
date_str = datetime.datetime.now().strftime("%Y%m%d")
|
date_str = datetime.datetime.now().strftime("%Y%m%d")
|
||||||
@@ -484,12 +491,14 @@ class TaskScheduler:
|
|||||||
self.data_processor.process_status_data(status_file_path)
|
self.data_processor.process_status_data(status_file_path)
|
||||||
|
|
||||||
# 发送通知
|
# 发送通知
|
||||||
self.config.dingtalk.send_text(f"{date_str}: 比赛状态更新完成")
|
self.config.dingtalk.send_text(
|
||||||
|
f"{date_str}: 比赛状态更新完成\n{config_base_info}"
|
||||||
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_info = traceback.format_exc()
|
error_info = traceback.format_exc()
|
||||||
logger.error(f"拉取任务失败: {error_info}")
|
logger.error(f"拉取任务失败: {error_info}")
|
||||||
self.config.dingtalk.send_text(error_info)
|
self.config.dingtalk.send_text(f"{config_base_info}\n{error_info}")
|
||||||
|
|
||||||
|
|
||||||
class BetTrackerApplication:
|
class BetTrackerApplication:
|
||||||
|
|||||||
Reference in New Issue
Block a user