#!/usr/bin/env python3
"""Check if server.py init_engine actually ran and what happened."""
import subprocess, sys

# Check if there's a running python process and what it looks like
result = subprocess.run(["ps", "aux"], capture_output=True, text=True)
for line in result.stdout.split("\n"):
    if "python" in line.lower():
        print(line)

print("\n=== Test: replicate server.py init_engine exactly ===")
import os
MODEL_DIR = "/models/qwen3-tts"
engine = None

def init_engine():
    global engine, MODEL_DIR
    print(f"  init_engine called, MODEL_DIR={MODEL_DIR}")
    try:
        from qwen3_tts_gguf.inference import TTSEngine
        print(f"  TTSEngine imported: {TTSEngine}")
        engine = TTSEngine(model_dir=MODEL_DIR)
        print(f"  engine created: {engine}")
        print(f"  engine is None: {engine is None}")
        print(f"  bool(engine): {bool(engine)}")
    except Exception as e:
        print(f"  EXCEPTION in init_engine: {e}")
        import traceback
        traceback.print_exc()

init_engine()
print(f"\n=== Result: engine={engine}, bool(engine)={bool(engine) if engine else 'N/A (None)'} ===")
