Compare commits

...

4 Commits

Author SHA1 Message Date
thuongnht c9b539abea
Merge pull request #6 from thebaptiste/metwork
fix: in ssh_process, we exit(1) only if the exit code of the ssh command is not 0
2021-03-05 12:28:50 +01:00
Jean-Baptiste VESLIN 5aa3c5e8d1
Update app.py 2021-03-05 10:36:08 +01:00
Jean-Baptiste VESLIN 1e8a5783bc
feat: use ssh command exit code 2021-03-05 10:18:23 +01:00
Jean-Baptiste VESLIN fed5e4953c
fix: don't exit(1) if both err and out are not empty 2021-03-05 10:05:00 +01:00
1 changed files with 5 additions and 0 deletions

5
app.py
View File

@ -96,6 +96,8 @@ def ssh_process(ssh, input_ssh):
stdin, stdout, stderr = ssh.exec_command(command_str)
ssh_exit_status = stdout.channel.recv_exit_status()
out = "".join(stdout.readlines())
out = out.strip() if out is not None else None
if out:
@ -105,6 +107,9 @@ def ssh_process(ssh, input_ssh):
err = err.strip() if err is not None else None
if err:
print(f"Error: \n{err}")
if ssh_exit_status != 0:
print(f"ssh exit status: {ssh_exit_status}")
sys.exit(1)
pass