优化日志输出

This commit is contained in:
jingrow 2025-08-21 22:45:08 +08:00
parent 4940177a5b
commit cafb0811b5

View File

@ -442,7 +442,7 @@ def find_org(org_repo, using_cached: bool = False):
# 1. 检测 SSH 配置
ssh_available = _check_ssh_availability()
print(f"SSH detection result: {ssh_available}")
print(f"SSH availability: {ssh_available}")
# 2. SSH 优先尝试
if ssh_available:
@ -453,7 +453,7 @@ def find_org(org_repo, using_cached: bool = False):
return org, org_repo
# 3. HTTP 回退
print("Falling back to HTTP method...")
print("Try HTTP method...")
username, password = _get_http_credentials()
for org in ["jingrow", "jerp"]:
if _try_http_access(org, org_repo, username, password):
@ -474,7 +474,6 @@ def _check_ssh_availability():
try:
# 直接测试 SSH 连接(使用配置的端口)
ssh_cmd = ['ssh', '-p', str(GIT_SSH_PORT), '-T', f'{GIT_SSH_USER}@{GIT_SSH_HOST}']
print(f"SSH connection test command: {' '.join(ssh_cmd)}")
result = subprocess.run(
ssh_cmd,
@ -482,14 +481,11 @@ def _check_ssh_availability():
text=True,
timeout=10
)
print(f"SSH connection test: returncode={result.returncode}, stdout='{result.stdout}', stderr='{result.stderr}'")
# SSH 成功或认证失败都说明 SSH 可用returncode 0 或 1
ssh_available = result.returncode in [0, 1]
print(f"SSH availability: {ssh_available}")
return ssh_available
except Exception as e:
print(f"SSH detection exception: {e}")
return False