"""labrun.py を設定を変えながら連続実行し、毎回 DB を初期状態(dbcopy)に戻してから始める。 結果は _lab2/lab_batch_summary.txt に追記。 使い方: python labbatch.py <分/回> ... cfg 例: mt2 mt0 mt8 """ import shutil, subprocess, sys, time from pathlib import Path HERE = Path(__file__).parent LAB = Path(r"C:\Users\PC_User\Desktop\AOIROSERVER2\_lab2") DBSRC = HERE / "dbcopy" DBDST = LAB / "worlds" / "lab" / "db" minutes = sys.argv[1] cfgs = sys.argv[2:] CFG = { "mt2": ["max-threads=2"], "mt0": ["max-threads=0"], "mt8": ["max-threads=8"], "mt1": ["max-threads=1"], "csg0": ["max-threads=2", "client-side-chunk-generation-enabled=false"], "nopack": ["max-threads=2"], # パック全部OFF(world_*_packs.json を空にする) "clean": ["max-threads=2"], # DB を復元しない(前回の続き=きれいなDB) # np_* = パック全部OFF + 追加設定(速く落ちる条件で対策候補を試す) "np_csg0": ["max-threads=2", "client-side-chunk-generation-enabled=false"], "np_mt0": ["max-threads=0", "client-side-chunk-generation-enabled=true"], "np_mt1": ["max-threads=1", "client-side-chunk-generation-enabled=true"], "np_mt8": ["max-threads=8", "client-side-chunk-generation-enabled=true"], "np_clean": ["max-threads=2", "client-side-chunk-generation-enabled=true"], # DB 復元なし "np_nofill": ["max-threads=2", "client-side-chunk-generation-enabled=true", "lab.fill=0"], } COMMON = ["lab.rect=1", "lab.dwell=2", "lab.fill=10"] out = LAB / "lab_batch_summary.txt" WJ = [LAB / "worlds" / "lab" / "world_behavior_packs.json", LAB / "worlds" / "lab" / "world_resource_packs.json"] for w in WJ: if not w.with_suffix(".json.orig").exists(): shutil.copy(w, w.with_suffix(".json.orig")) for i, cfg in enumerate(cfgs, 1): if cfg not in ("clean", "np_clean"): if DBDST.exists(): shutil.rmtree(DBDST) shutil.copytree(DBSRC, DBDST) (DBDST / "LOCK").unlink(missing_ok=True) for w in WJ: if cfg == "nopack" or cfg.startswith("np_"): w.write_text("[]", encoding="utf-8") else: shutil.copy(w.with_suffix(".json.orig"), w) tag = f"b{i}_{cfg}_{time.strftime('%H%M')}" r = subprocess.run([sys.executable, str(HERE / "labrun.py"), tag, minutes] + CFG[cfg] + COMMON, capture_output=True, text=True, encoding="utf-8", errors="replace") summ = [l for l in r.stdout.splitlines() if l.startswith("SUMMARY")] line = f"{time.strftime('%m/%d %H:%M')} {cfg}: {summ[-1] if summ else 'SUMMARY無し rc=' + str(r.returncode)}" with open(out, "a", encoding="utf-8") as f: f.write(line + "\n") print(line, flush=True) time.sleep(5)