You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by xu...@apache.org on 2016/11/16 05:17:43 UTC
incubator-airflow git commit: [AIRFLOW-130] Fix ssh operator macosx
Repository: incubator-airflow
Updated Branches:
refs/heads/master 77ef48e05 -> 664e63a72
[AIRFLOW-130] Fix ssh operator macosx
Copy existing shell environment instead of
overwriting
Testing Done:
- Unit tests previously did not pass on Mac OS X,
now pass.
Fix typos in comments
Fix failing test when setting env for SSHHook on
Mac OS X
Add logging and use os.environ.copy() to set env
in popen fixes test.
Move import to top of file
Closes #1778 from jbhsieh/fix_ssh_operator_macosx
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/664e63a7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/664e63a7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/664e63a7
Branch: refs/heads/master
Commit: 664e63a72d3b6dcacf10ae019a16109fa5c7beea
Parents: 77ef48e
Author: Julia Hsieh <jh...@domaintools.com>
Authored: Wed Nov 16 00:12:47 2016 -0500
Committer: Li Xuanji <xu...@gmail.com>
Committed: Wed Nov 16 00:13:14 2016 -0500
----------------------------------------------------------------------
airflow/contrib/operators/ssh_execute_operator.py | 6 ++++--
tests/contrib/operators/ssh_execute_operator.py | 5 ++++-
2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/664e63a7/airflow/contrib/operators/ssh_execute_operator.py
----------------------------------------------------------------------
diff --git a/airflow/contrib/operators/ssh_execute_operator.py b/airflow/contrib/operators/ssh_execute_operator.py
index 2a6176d..dd4c3b4 100644
--- a/airflow/contrib/operators/ssh_execute_operator.py
+++ b/airflow/contrib/operators/ssh_execute_operator.py
@@ -38,9 +38,9 @@ class SSHTempFileContent(object):
:param ssh_hook: A SSHHook that indicates a remote host
where you want to create tempfile
- :param content: Initial content of creating temprary file
+ :param content: Initial content of creating temporary file
:type content: string
- :param prefix: The prefix string you want to use for the temprary file
+ :param prefix: The prefix string you want to use for the temporary file
:type prefix: string
"""
@@ -129,6 +129,8 @@ class SSHExecuteOperator(BaseOperator):
logging.info("Temporary script "
"location : {0}:{1}".format(host, remote_file_path))
logging.info("Running command: " + bash_command)
+ if self.env is not None:
+ logging.info("env: " + str(self.env))
sp = hook.Popen(
['-q', 'bash', remote_file_path],
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/664e63a7/tests/contrib/operators/ssh_execute_operator.py
----------------------------------------------------------------------
diff --git a/tests/contrib/operators/ssh_execute_operator.py b/tests/contrib/operators/ssh_execute_operator.py
index 2975726..ef8162c 100644
--- a/tests/contrib/operators/ssh_execute_operator.py
+++ b/tests/contrib/operators/ssh_execute_operator.py
@@ -13,6 +13,7 @@
# limitations under the License.
import unittest
+import os
from datetime import datetime
from airflow import configuration
@@ -62,11 +63,13 @@ class SSHExecuteOperatorTest(unittest.TestCase):
task.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)
def test_with_env(self):
+ test_env = os.environ.copy()
+ test_env['AIRFLOW_test'] = "test"
task = SSHExecuteOperator(
task_id="test",
bash_command="echo $AIRFLOW_HOME",
ssh_hook=self.hook,
- env={"AIRFLOW_test": "test"},
+ env=test_env,
dag=self.dag,
)
task.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)