# -*- coding: utf-8 -*- import paramiko HOST = "107.173.30.245" USER = "root" PASSWORD = "Xiao4669805" H = "b55f4b6" def main() -> None: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, 22, USER, PASSWORD, timeout=30, allow_agent=False, look_for_keys=False) tmp = f"/tmp/monitor_{H}.db" cmd = ( "cd /opt/douyinWEB && " f"git show {H}:backend/data/monitor.db > {tmp} && " "python3 -c \"import sqlite3; " f"conn=sqlite3.connect('{tmp}'); " "print(conn.execute('select count(*) from shorts_channels').fetchone()[0])\"" ) _stdin, stdout, stderr = c.exec_command(cmd, timeout=180) out = stdout.read().decode('utf-8', 'replace') err = stderr.read().decode('utf-8', 'replace') print(out.strip()) if err.strip(): print('err:', err.strip()) c.close() if __name__ == "__main__": main()