Files
Accusys 3d441a1c76 release: v1.3.2 - Cross-Machine Deployment Support
Major Changes:
- Removed all hardcoded paths for cross-machine deployment
- Added unified path management module (path_utils.rs)
- Supports arbitrary user home directories
- Environment variable configuration for all paths

New Features:
- path_utils module with 15+ path resolution functions
- Dynamic user home directory detection
- Environment variable overrides for all paths
- Default paths using $HOME/momentry and $HOME/momentry_core

Fixed Files:
- Rust code: 8 core files (release.rs, service.rs, markbase_compat.rs, etc.)
- Python scripts: 10 files (ASR, ASRX, Face, Identity, VLM, Migration)
- Configuration: production.env (removed hardcoded paths)

Environment Variables Supported:
- HOME - User home directory
- MOMENTRY_ROOT - Momentry root directory
- MOMENTRY_CORE_DIR - Momentry_core directory
- MOMENTRY_OUTPUT_DIR - Output directory
- MOMENTRY_BACKUP_DIR - Backup directory
- MOMENTRY_STORAGE_ROOT - Storage root directory
- MOMENTRY_SCRIPTS_DIR - Scripts directory
- MOMENTRY_CLI_DIR - CLI tools directory

Breaking Changes:
- None (backward compatible with environment variables)

Deployment:
- Can now deploy to any machine with any username
- No hardcoded /Users/accusys paths in core functionality
- Ready for M4ProMini deployment (/Users/nextorageai)
2026-10-12 13:20:45 +08:00

139 lines
3.5 KiB
Python

#!/usr/bin/env python3
"""
迁移工具 - 一键执行所有迁移任务
执行顺序:
1. 生成 File Profile 文件
2. 生成 Identity Profile 文件
3. 更新 Trace Profile 文件
4. 生成索引文件
Usage:
python3 migrate_all.py [--dry-run]
"""
import argparse
import subprocess
import sys
from pathlib import Path
def run_script(script_path: str, args: list = None, dry_run: bool = False) -> bool:
"""运行迁移脚本"""
cmd = ["python3", script_path]
if args:
cmd.extend(args)
if dry_run:
cmd.append("--dry-run")
print(f"\n执行: {' '.join(cmd)}")
print("=" * 60)
try:
result = subprocess.run(cmd, check=True)
return result.returncode == 0
except subprocess.CalledProcessError as e:
print(f"❌ 脚本执行失败: {e}")
return False
except Exception as e:
print(f"❌ 意外错误: {e}")
return False
def main():
parser = argparse.ArgumentParser(description="一键执行所有迁移任务")
parser.add_argument(
"--dry-run",
action="store_true",
help="只打印将要执行的操作,不实际写入文件"
)
parser.add_argument(
"--output-dir",
default=os.path.expanduser("~/momentry/output"),
help="输出目录"
)
parser.add_argument(
"--identities-dir",
default=os.path.expanduser("~/momentry/identities"),
help="Identity 目录"
)
parser.add_argument(
"--database",
default="momentry",
help="数据库名称"
)
args = parser.parse_args()
print("=" * 60)
print("三段式实体文件持久化迁移工具")
print("=" * 60)
print()
print(f"输出目录: {args.output_dir}")
print(f"Identity 目录: {args.identities_dir}")
print(f"数据库: {args.database}")
print(f"Dry run: {args.dry_run}")
print()
# 脚本目录
script_dir = Path(__file__).parent
# 任务列表
tasks = [
{
"name": "生成 File Profile 文件",
"script": str(script_dir / "generate_profiles.py"),
"args": [
"--output-dir", args.output_dir,
"--database", args.database
]
},
{
"name": "生成 Identity Profile 文件",
"script": str(script_dir / "generate_identities.py"),
"args": [
"--identities-dir", args.identities_dir,
"--database", args.database
]
}
]
# 执行任务
success_count = 0
failed_count = 0
for task in tasks:
print()
print(f"任务: {task['name']}")
print("-" * 60)
if run_script(task["script"], task.get("args"), args.dry_run):
success_count += 1
else:
failed_count += 1
print(f"⚠️ 任务失败: {task['name']}")
response = input("继续下一个任务? (y/n): ")
if response.lower() != 'y':
print("迁移已中止")
break
# 总结
print()
print("=" * 60)
print("迁移完成")
print("=" * 60)
print(f"成功任务: {success_count}")
print(f"失败任务: {failed_count}")
if args.dry_run:
print()
print("这是 DRY-RUN 模式,没有实际写入文件")
print("移除 --dry-run 参数以实际执行")
if failed_count > 0:
sys.exit(1)
if __name__ == "__main__":
main()