diff --git a/scripts/deploy_remote.py b/scripts/deploy_remote.py index bfc83da..bb49418 100644 --- a/scripts/deploy_remote.py +++ b/scripts/deploy_remote.py @@ -54,12 +54,23 @@ curl -fsS http://127.0.0.1:5155/health || true client.connect(HOST, username=USER, password=PASSWORD, timeout=30) print("running remote bootstrap/pull ...") stdin, stdout, stderr = client.exec_command(remote, get_pty=True) - for line in iter(stdout.readline, ""): - print(line, end="") - err = stderr.read().decode("utf-8", errors="ignore") + while True: + chunk = stdout.read(1024) + if not chunk: + break + text = chunk.decode("utf-8", errors="replace") if isinstance(chunk, bytes) else chunk + try: + print(text, end="", flush=True) + except UnicodeEncodeError: + print(text.encode("ascii", errors="replace").decode("ascii"), end="", flush=True) + err_raw = stderr.read() + err = err_raw.decode("utf-8", errors="replace") if isinstance(err_raw, bytes) else err_raw code = stdout.channel.recv_exit_status() if err: - print(err, file=sys.stderr) + try: + print(err, file=sys.stderr) + except UnicodeEncodeError: + print(err.encode("ascii", errors="replace").decode("ascii"), file=sys.stderr) client.close() print(f"exit={code}") return code