Signed-off-by: 南通一次元科技有限公司 <guwangtu@icimeta.com>
This commit is contained in:
commit
b91954df4a
106 files changed
+43359
No files matched your search
@@ -0,0 +1,67 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""公共模块同步工具
|
||||
|
||||
当前平台由四个独立 FastAPI 服务组成,公共模块统一放在 shared/ 目录维护,
|
||||
再同步到四个项目目录,避免出现“四份代码不一致”。
|
||||
|
||||
用法:
|
||||
python deploy/同步公共模块.py # 同步 shared/ 到四个项目
|
||||
python deploy/同步公共模块.py --check # 只检查是否一致,不写入
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
WORKSPACE = Path(__file__).resolve().parent.parent
|
||||
PROJECTS = ["综合管理平台", "审计项目管理平台", "风险管理项目", "合同审核管理平台"]
|
||||
SHARED_MODULES = ["auth_guard.py", "pdf_tools.py"]
|
||||
|
||||
|
||||
def md5(path: Path) -> str:
|
||||
return hashlib.md5(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--check", action="store_true", help="只检查不写入")
|
||||
args = parser.parse_args()
|
||||
|
||||
shared_dir = WORKSPACE / "shared"
|
||||
problems = 0
|
||||
for module in SHARED_MODULES:
|
||||
src = shared_dir / module
|
||||
if not src.exists():
|
||||
print(f"[错误] 缺少公共模块:shared/{module}")
|
||||
problems += 1
|
||||
continue
|
||||
src_hash = md5(src)
|
||||
for project in PROJECTS:
|
||||
dst = WORKSPACE / project / module
|
||||
if not dst.exists():
|
||||
if args.check:
|
||||
print(f"[缺失] {project}/{module}")
|
||||
problems += 1
|
||||
else:
|
||||
shutil.copy2(src, dst)
|
||||
print(f"[已创建] {project}/{module}")
|
||||
continue
|
||||
if md5(dst) == src_hash:
|
||||
print(f"[一致] {project}/{module}")
|
||||
continue
|
||||
if args.check:
|
||||
print(f"[不一致] {project}/{module}")
|
||||
problems += 1
|
||||
else:
|
||||
shutil.copy2(src, dst)
|
||||
print(f"[已同步] {project}/{module}")
|
||||
if problems:
|
||||
print(f"\n检查完成:发现 {problems} 处问题")
|
||||
return 1
|
||||
print("\n检查完成:公共模块全部一致")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user