106 lines
2.7 KiB
Python
106 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""等待 DGXA → 已验收 RockBall.fbx → TokenRig+UniMate → 入库 → SetupAnimalAnimator。"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
REPO = Path(__file__).resolve().parents[1]
|
|
NVSYNC = Path(
|
|
os.environ.get("LOCALAPPDATA", "")
|
|
) / "Programs/nvidia-sync/resources/bin/nvsync-amd64.exe"
|
|
|
|
|
|
def ssh_ready() -> bool:
|
|
try:
|
|
r = subprocess.run(
|
|
["ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=8", "DGXA", "echo READY"],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=20,
|
|
)
|
|
return r.returncode == 0 and "READY" in (r.stdout or "")
|
|
except Exception:
|
|
return False
|
|
|
|
|
|
def nvsync_connect() -> None:
|
|
if not NVSYNC.is_file():
|
|
return
|
|
try:
|
|
subprocess.run(
|
|
[str(NVSYNC), "connect", "DGXA", "--detach"],
|
|
timeout=100,
|
|
check=False,
|
|
capture_output=True,
|
|
)
|
|
except subprocess.TimeoutExpired:
|
|
pass
|
|
|
|
|
|
def main() -> int:
|
|
print("=== wait DGXA ===", flush=True)
|
|
for attempt in range(1, 121):
|
|
print(f"attempt {attempt}", flush=True)
|
|
nvsync_connect()
|
|
if ssh_ready():
|
|
break
|
|
time.sleep(15)
|
|
else:
|
|
print("DGXA still unreachable after wait", flush=True)
|
|
return 2
|
|
|
|
caps = subprocess.run(
|
|
[sys.executable, str(REPO / "Tools/dgx3d_animal_pipeline.py"), "--caps-only"],
|
|
cwd=str(REPO),
|
|
)
|
|
if caps.returncode != 0:
|
|
return caps.returncode
|
|
|
|
mesh = REPO / "AIClient/Assets/Bundles/Characters/Animal/RockBall/RockBall.fbx"
|
|
cmd = [
|
|
sys.executable,
|
|
str(REPO / "Tools/dgx3d_animal_pipeline.py"),
|
|
"--mesh",
|
|
str(mesh),
|
|
"-o",
|
|
str(REPO / "Tools/output/rockball_dgx"),
|
|
"--name",
|
|
"RockBall",
|
|
]
|
|
print("RUN", " ".join(cmd), flush=True)
|
|
r = subprocess.run(cmd, cwd=str(REPO))
|
|
if r.returncode != 0:
|
|
return r.returncode
|
|
|
|
manifest = REPO / "Tools/output/rockball_dgx/RockBall_manifest.json"
|
|
r = subprocess.run(
|
|
[sys.executable, str(REPO / "Tools/install_animal_rigged.py"), "-m", str(manifest)],
|
|
cwd=str(REPO),
|
|
)
|
|
if r.returncode != 0:
|
|
return r.returncode
|
|
|
|
r = subprocess.run(
|
|
[
|
|
"unity",
|
|
"command",
|
|
"--project-path",
|
|
"D:/UD/AI/AIGame/AIClient",
|
|
"run_script",
|
|
"--file",
|
|
"AgentScripts/SetupAnimalAnimator.cs",
|
|
"--entry",
|
|
"SetupAnimalAnimator.SetupRockBall",
|
|
],
|
|
cwd=str(REPO),
|
|
)
|
|
return r.returncode
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|