"""Read raw ComfyUI log - no filtering, no quoting issues."""
import paramiko

k = paramiko.Ed25519Key.from_private_key_file(r'C:\Users\fabia\.ssh\id_ed25519')
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('192.168.178.150', username='fabian', pkey=k, timeout=10)

# Read the ENTIRE log via SFTP - no shell, no grep, no quoting
sftp = c.open_sftp()
try:
    with sftp.open('/tmp/comfyui.log', 'r') as f:
        log = f.read().decode(errors='replace')
    
    lines = log.split('\n')
    print(f"Total log lines: {len(lines)}")
    print()
    
    # Print everything that's NOT ComfyUI-Manager registry spam
    for line in lines:
        if 'FETCH ComfyRegistry' in line:
            continue
        if 'All startup tasks' in line:
            continue
        if line.strip():
            print(line)
except Exception as e:
    print(f"Error reading log: {e}")
finally:
    sftp.close()

# Also check: is the process actually using GPU memory?
chan = c.get_transport().open_session()
chan.settimeout(10)
chan.exec_command('/bin/bash -c "rocm-smi --showmeminfo vram 2>/dev/null"')
out = b""
while True:
    try:
        chunk = chan.recv(65536)
        if not chunk: break
        out += chunk
    except: break
chan.close()
print("\n=== VRAM Info ===")
print(out.decode(errors='replace'))

c.close()
