chore: auto release commit (2026-09-15 00:32:44)
All checks were successful
技能自动化发布 / release (push) Successful in 7s
All checks were successful
技能自动化发布 / release (push) Successful in 7s
This commit is contained in:
@@ -279,6 +279,72 @@ def cmd_parse_materials(args: argparse.Namespace) -> int:
|
||||
conn.close()
|
||||
|
||||
|
||||
def cmd_import_input(_args: argparse.Namespace) -> int:
|
||||
"""扫描 data/input/{contracts,materials}/ 自动入库。
|
||||
|
||||
约定:
|
||||
input/contracts/*.csv → contracts 表 upsert
|
||||
input/materials/{cid}__{f}.pdf → materials_content (parse_method='pending')
|
||||
"""
|
||||
from service.importer import import_input_dir
|
||||
|
||||
conn = get_connection()
|
||||
try:
|
||||
result = import_input_dir(conn)
|
||||
finally:
|
||||
conn.close()
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_download_materials(args: argparse.Namespace) -> int:
|
||||
"""处理 download_tasks 队列:抓 pending 任务的材料 → 落库。
|
||||
|
||||
--ids "DLQ-xxx,DLQ-yyy": 只处理这些任务
|
||||
--pick N: 无 --ids 时从 pending 领取 N 条(默认 5)
|
||||
--limit N: 本次硬上限(默认 0 = 不限)
|
||||
--headless: 无头模式(需要 profile cookie 已保存)
|
||||
"""
|
||||
try:
|
||||
result = platform_collector.process_queue(
|
||||
limit=args.limit or args.pick,
|
||||
ids_filter=args.ids,
|
||||
headless=args.headless,
|
||||
human_wait_timeout=args.human_wait_timeout or HUMAN_WAIT_TIMEOUT,
|
||||
)
|
||||
except platform_collector.RPAError as e:
|
||||
print(json.dumps({
|
||||
"error": e.code,
|
||||
"detail": str(e),
|
||||
"processed": 0, "succeeded": 0, "failed": 0, "details": [],
|
||||
}, ensure_ascii=False, indent=2))
|
||||
return 2
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": "exception", "detail": str(e)},
|
||||
ensure_ascii=False, indent=2))
|
||||
return 1
|
||||
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_show_config(_args: argparse.Namespace) -> int:
|
||||
"""查看 .env 非空配置(敏感字段自动脱敏)。"""
|
||||
from service.config_viewer import read_env_config
|
||||
|
||||
print(json.dumps(read_env_config(), ensure_ascii=False, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_logs_list(args: argparse.Namespace) -> int:
|
||||
"""读取日志末尾 N 行(默认 200)。"""
|
||||
from service.logs_viewer import tail_log_file
|
||||
|
||||
result = tail_log_file(tail=args.tail, min_level=args.level)
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
# ---------- argparse ----------
|
||||
|
||||
def _parse_thresholds(s: str) -> tuple[int, int, int]:
|
||||
@@ -360,6 +426,41 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
help="仅解析该合同(留空=处理所有 pending)")
|
||||
sp.set_defaults(handler=cmd_parse_materials)
|
||||
|
||||
sp = sub.add_parser(
|
||||
"download-materials",
|
||||
help="处理材料下载队列(pending 任务 → 浏览器抓取 → 落库)",
|
||||
)
|
||||
sp.add_argument("--limit", type=int, default=0, help="本次最多处理任务数(0 = 用 --pick)")
|
||||
sp.add_argument("--ids", default="", help="逗号分隔 task_id 列表(仅处理这些 pending 任务)")
|
||||
sp.add_argument("--pick", type=int, default=5, help="无 --ids 时从 pending 领取条数(默认 5)")
|
||||
sp.add_argument("--headless", action="store_true", help="无头模式(需已保存 profile)")
|
||||
sp.add_argument("--show-browser", dest="headless", action="store_false",
|
||||
help=argparse.SUPPRESS)
|
||||
sp.add_argument("--human-wait-timeout", type=int, default=None,
|
||||
help="手工登录 fallback 等待秒数(默认 180 = HUMAN_WAIT_TIMEOUT)")
|
||||
sp.set_defaults(headless=False, handler=cmd_download_materials)
|
||||
|
||||
sp = sub.add_parser(
|
||||
"import-input",
|
||||
help="扫描 data/input/{contracts,materials}/ 自动入库",
|
||||
)
|
||||
sp.set_defaults(handler=cmd_import_input)
|
||||
|
||||
sp = sub.add_parser(
|
||||
"show-config",
|
||||
help="查看 .env 配置(敏感字段自动脱敏)",
|
||||
)
|
||||
sp.set_defaults(handler=cmd_show_config)
|
||||
|
||||
sp = sub.add_parser(
|
||||
"logs-list",
|
||||
help="查看运行日志末尾 N 行",
|
||||
)
|
||||
sp.add_argument("--tail", type=int, default=200, help="末尾行数(默认 200)")
|
||||
sp.add_argument("--level", default="INFO",
|
||||
help="最低级别 DEBUG/INFO/WARNING/ERROR(默认 INFO)")
|
||||
sp.set_defaults(handler=cmd_logs_list)
|
||||
|
||||
return p
|
||||
|
||||
|
||||
@@ -370,7 +471,8 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
print("Commands: health, version, config-path, init-db, "
|
||||
"scan-expiring-contracts, generate-renewal-task, "
|
||||
"dispatch-task-notice, mark-contract-renewed, render-html, "
|
||||
"collect-from-platform, parse-materials")
|
||||
"collect-from-platform, parse-materials, download-materials, "
|
||||
"import-input, show-config, logs-list")
|
||||
return 1
|
||||
|
||||
setup_skill_logging()
|
||||
|
||||
Reference in New Issue
Block a user