aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincenzo Maffione <v.maffione@gmail.com>2017-04-12 16:11:51 +0200
committerVincenzo Maffione <v.maffione@gmail.com>2017-04-12 16:11:51 +0200
commitee019d830260a80299bd5afc734a18df37edb3b2 (patch)
treeed2b79e3e370bbd19466e44091faa05e68ff7ee1
parent6d8d0d30d75b318650034470b376a57a37b57944 (diff)
downloadrumba-ee019d830260a80299bd5afc734a18df37edb3b2.tar.gz
rumba-ee019d830260a80299bd5afc734a18df37edb3b2.zip
ssh_support: print both stdout and stderr for ssh commands
-rw-r--r--rumba/ssh_support.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index ad32d13..34e65e0 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -27,6 +27,13 @@ def get_ssh_client():
return ssh_client
+def _print_stream(stream):
+ o = str(stream.read()).strip('b\'\"\\n')
+ if o != "":
+ o_array = o.split('\\n')
+ for oi in o_array:
+ print(oi)
+
def execute_commands(testbed, ssh_config, commands, time_out=3):
'''
Remote execution of a list of shell command on hostname. By
@@ -49,12 +56,8 @@ def execute_commands(testbed, ssh_config, commands, time_out=3):
look_for_keys=True, timeout=time_out)
for command in commands:
stdin, stdout, stderr = ssh_client.exec_command(command)
- del stdin, stdout
- err = str(stderr.read()).strip('b\'\"\\n')
- if err != "":
- err_array = err.split('\\n')
- for erra in err_array:
- print(erra)
+ _print_stream(stdout)
+ _print_stream(stderr)
ssh_client.close()
except Exception as e: