#!/usr/bin/env python3
import sys

import paramiko

sys.stdout.reconfigure(encoding="utf-8", errors="replace")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("192.168.10.162", username="morteza", password="Moli@5404", timeout=30, allow_agent=False, look_for_keys=False)
cmds = [
    "cat /home/morteza/torbatyar/infrastructure/keycloak/themes/torbatyar/login/theme.properties",
    "docker exec superapp_keycloak cat /opt/keycloak/themes/torbatyar/login/theme.properties",
    "docker exec superapp_keycloak wget -qO- http://127.0.0.1:8080/realms/superapp 2>/dev/null | head -c 300 || curl -s http://127.0.0.1:8080/realms/superapp | head -c 300",
]
for cmd in cmds:
    print(">>>", cmd)
    _, stdout, stderr = c.exec_command(cmd, timeout=30, get_pty=True)
    print((stdout.read() + stderr.read()).decode("utf-8", "replace"))
    print("---")
c.close()
