Add more verbose error on --verbose

This commit is contained in:
allegroai 2024-05-20 15:52:46 +03:00
parent 5b9b09e1f7
commit f6fe1cff56

View File

@ -843,10 +843,12 @@ def start_ssh_tunnel(username, remote_address, ssh_port, ssh_password, local_rem
# store SSH output # store SSH output
fd = StringIO() if debug else sys.stdout fd = StringIO() if debug else sys.stdout
command = None
# noinspection PyBroadException # noinspection PyBroadException
try: try:
command = _check_ssh_executable()
child = pexpect.spawn( child = pexpect.spawn(
command=_check_ssh_executable(), command=command,
args=args, args=args,
logfile=fd, timeout=20, encoding='utf-8') logfile=fd, timeout=20, encoding='utf-8')
@ -880,8 +882,14 @@ def start_ssh_tunnel(username, remote_address, ssh_port, ssh_password, local_rem
raise ValueError('Incorrect password') raise ValueError('Incorrect password')
except pexpect.TIMEOUT: except pexpect.TIMEOUT:
pass pass
except Exception: except Exception as ex:
child.terminate(force=True) if debug:
print("ERROR: running local SSH client [{}] failed connecting to {}: {}".format(command, args, ex))
else:
print("ERROR: running local SSH client failed connecting to {}: {}".format(remote_address, ex))
if child:
child.terminate(force=True)
child = None child = None
print('\n') print('\n')
if child: if child: