|
| 1 | +"""Temporary: instrument the ubuntu-runner-only failure of |
| 2 | +tests/test_menubar.py::test_creating_a_vault_really_works. Deleted before merge.""" |
| 3 | +import json, os, pathlib, subprocess, sys, tempfile |
| 4 | + |
| 5 | +td = tempfile.mkdtemp() |
| 6 | +home = pathlib.Path(td) / "home" |
| 7 | +home.mkdir() |
| 8 | +os.environ["HOME"] = str(home) |
| 9 | +os.environ["HERMES_HOME"] = str(home / ".hermes") |
| 10 | +os.environ["OPENCLAW_HOME"] = str(home / ".openclaw") |
| 11 | + |
| 12 | +from compartment import menubar, session, platforms # noqa: E402 |
| 13 | + |
| 14 | +vault = str(home / ".compartment" / "memory.vault") |
| 15 | +print("== env ==") |
| 16 | +print("uid:", os.getuid(), "| HOME:", os.environ["HOME"]) |
| 17 | +print("machine-id:", repr(open("/etc/machine-id").read()) if os.path.exists("/etc/machine-id") else "ABSENT") |
| 18 | +print("dbus id:", os.path.exists("/var/lib/dbus/machine-id")) |
| 19 | +print("btime:", [l for l in open("/proc/stat") if l.startswith("btime")]) |
| 20 | +print("shm before:", os.listdir("/dev/shm")) |
| 21 | + |
| 22 | +ok, msg = menubar.create_vault(vault, "CorrectHorse", "CorrectHorse") |
| 23 | +print("== create_vault ==", ok, "|", msg) |
| 24 | +sdir = session._session_dir() |
| 25 | +print("session dir:", sdir, "->", os.listdir(sdir)) |
| 26 | +print("holder name:", session._holder()) |
| 27 | +print("shm after init:", os.listdir("/dev/shm")) |
| 28 | +f = session._file_for(vault) |
| 29 | +print("credential file:", f, "exists:", f.is_file()) |
| 30 | +if f.is_file(): |
| 31 | + print("credential doc:", json.loads(f.read_text())["v"], "vault field ok") |
| 32 | + |
| 33 | +print("== raw CLI status child ==") |
| 34 | +argv = menubar._cli_argv() |
| 35 | +out = subprocess.run([*argv, "--vault", vault, "status"], capture_output=True, text=True) |
| 36 | +print("rc:", out.returncode) |
| 37 | +print("stdout:", out.stdout[:1200]) |
| 38 | +print("stderr:", out.stderr[:1200]) |
| 39 | +print("credential file after status:", f.is_file()) |
| 40 | + |
| 41 | +print("== in-process session.get ==") |
| 42 | +try: |
| 43 | + got = session.get(vault) |
| 44 | + print("get ->", "KEY" if got else "None", "| file still there:", f.is_file()) |
| 45 | +except Exception as exc: |
| 46 | + print("get raised:", type(exc).__name__, exc) |
| 47 | + |
| 48 | +print("== fetch_state ==") |
| 49 | +st = menubar.fetch_state(vault) |
| 50 | +print("locked:", st["locked"], "| error:", st["error"], "| records:", st["records"]) |
| 51 | +print("== second CLI status ==") |
| 52 | +out2 = subprocess.run([*argv, "--vault", vault, "status"], capture_output=True, text=True) |
| 53 | +print("rc:", out2.returncode, "| locked in json:", '"locked": true' in out2.stdout or '"locked": True' in out2.stdout) |
| 54 | +print("stderr2:", out2.stderr[:400]) |
0 commit comments