|
@@ -43,7 +43,10 @@ def ssh_exec(cmd: str, timeout: int | None = None) -> tuple[int, str, str]:
|
|
|
text=True,
|
|
text=True,
|
|
|
timeout=timeout,
|
|
timeout=timeout,
|
|
|
)
|
|
)
|
|
|
- return proc.returncode, proc.stdout, proc.stderr
|
|
|
|
|
|
|
+ # 过滤 known_hosts 警告,这些不算真正的错误
|
|
|
|
|
+ clean_stderr = "\n".join(line for line in proc.stderr.split("\n")
|
|
|
|
|
+ if not line.startswith("Warning:"))
|
|
|
|
|
+ return proc.returncode, proc.stdout, clean_stderr
|
|
|
except subprocess.TimeoutExpired:
|
|
except subprocess.TimeoutExpired:
|
|
|
logger.error(f"SSH command timeout after {timeout}s: {cmd[:100]}")
|
|
logger.error(f"SSH command timeout after {timeout}s: {cmd[:100]}")
|
|
|
return -1, "", f"Command timed out after {timeout}s"
|
|
return -1, "", f"Command timed out after {timeout}s"
|