Repository: incubator-airflow
Updated Branches:
  refs/heads/master 5b06b6666 -> 0ba6ab6e5


[AIRFLOW-1712][AIRFLOW-756][AIRFLOW-751] Log SSHOperator output

SSHOperator does now write stdout to log, just
like SSHExecutorOperator
did in the past

Closes #2686 from OpringaoDoTurno/bring-ssh-logs-
back


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/0ba6ab6e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/0ba6ab6e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/0ba6ab6e

Branch: refs/heads/master
Commit: 0ba6ab6e5c5de0257dfc6f542c7396bda5c382b1
Parents: 5b06b66
Author: Ignasi Peiró <[email protected]>
Authored: Thu Nov 2 09:34:44 2017 +0100
Committer: Bolke de Bruin <[email protected]>
Committed: Thu Nov 2 09:34:44 2017 +0100

----------------------------------------------------------------------
 airflow/contrib/operators/ssh_operator.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/0ba6ab6e/airflow/contrib/operators/ssh_operator.py
----------------------------------------------------------------------
diff --git a/airflow/contrib/operators/ssh_operator.py 
b/airflow/contrib/operators/ssh_operator.py
index 897cd1a..bb72330 100644
--- a/airflow/contrib/operators/ssh_operator.py
+++ b/airflow/contrib/operators/ssh_operator.py
@@ -86,6 +86,12 @@ class SSHOperator(BaseOperator):
                                                             get_pty=get_pty,
                                                             
timeout=self.timeout
                                                             )
+            stdin.close()
+            output=b''
+            for line in stdout:
+                output+=line.encode('utf-8')
+                self.log.info(line.strip('\n'))
+
             exit_status = stdout.channel.recv_exit_status()
             if exit_status is 0:
                 # only returning on output if do_xcom_push is set
@@ -94,9 +100,9 @@ class SSHOperator(BaseOperator):
                     enable_pickling = configuration.getboolean('core',
                                                                
'enable_xcom_pickling')
                     if enable_pickling:
-                        return stdout.read()
+                        return output
                     else:
-                        return b64encode(stdout.read()).decode('utf-8')
+                        return b64encode(output).decode('utf-8')
 
             else:
                 error_msg = stderr.read()

Reply via email to