Centralize paths in paths.py and harden waybill-number handling
- Add paths.py: BASE_DIR/DOWNLOAD_DIR/CONFIG_PATH anchored on __file__ so paths resolve regardless of the launch cwd - Route main_router and all site modules through DOWNLOAD_DIR/CONFIG_PATH, replacing os.getcwd()-based download dirs and the "config.yaml" literal - main_router compare engine: read Excel as str with keep_default_na, strip/normalize 运单号, drop blanks, and isin against a set so int/float-vs-str mismatches no longer produce false "undelivered" - Shunxin: give downloaded files unique microsecond temp names and read Excel as str to preserve long-waybill precision - Normalize bare except: to except Exception: across affected files Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,12 +4,14 @@ import os
|
||||
import yaml
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
from paths import DOWNLOAD_DIR, CONFIG_PATH
|
||||
|
||||
|
||||
def baishi_download_undelivered_data(page):
|
||||
"""百世:一键提取应到未到(当日未扫)数据"""
|
||||
print("\n▶ 开始执行【百世 - 一键提取应到未到数据】任务...")
|
||||
|
||||
download_dir = os.path.join(os.getcwd(), "downloads")
|
||||
download_dir = DOWNLOAD_DIR
|
||||
if not os.path.exists(download_dir):
|
||||
os.makedirs(download_dir)
|
||||
|
||||
@@ -60,7 +62,7 @@ def baishi_download_undelivered_data(page):
|
||||
print(">> 正在读取本地配置文件并进行授权验证...")
|
||||
password = ""
|
||||
try:
|
||||
with open("config.yaml", "r", encoding="utf-8") as f:
|
||||
with open(CONFIG_PATH, "r", encoding="utf-8") as f:
|
||||
config = yaml.safe_load(f)
|
||||
password = config.get("baishi", {}).get("password", "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user