From 9ecb99210062d1ac3f2b3fa878338468cc94f664 Mon Sep 17 00:00:00 2001 From: cclauss Date: Thu, 3 May 2018 10:22:01 +0200 Subject: [PATCH] [AIRFLOW-2407] Resolve Python undefined names --- airflow/contrib/auth/backends/kerberos_auth.py | 3 ++- airflow/contrib/hooks/aws_hook.py | 1 + airflow/contrib/operators/datastore_export_operator.py | 1 + airflow/contrib/operators/datastore_import_operator.py | 3 +-- airflow/contrib/sensors/qubole_sensor.py | 3 ++- tests/operators/test_virtualenv_operator.py | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/airflow/contrib/auth/backends/kerberos_auth.py b/airflow/contrib/auth/backends/kerberos_auth.py index f6f9d6986a169..0dc8bd432d953 100644 --- a/airflow/contrib/auth/backends/kerberos_auth.py +++ b/airflow/contrib/auth/backends/kerberos_auth.py @@ -17,8 +17,9 @@ # specific language governing permissions and limitations # under the License. +import logging import flask_login -from flask_login import login_required, current_user, logout_user +from flask_login import current_user from flask import flash from wtforms import ( Form, PasswordField, StringField) diff --git a/airflow/contrib/hooks/aws_hook.py b/airflow/contrib/hooks/aws_hook.py index 29bf740dd72f5..c8ded4d2951c7 100644 --- a/airflow/contrib/hooks/aws_hook.py +++ b/airflow/contrib/hooks/aws_hook.py @@ -20,6 +20,7 @@ import boto3 import configparser +import logging from airflow.exceptions import AirflowException from airflow.hooks.base_hook import BaseHook diff --git a/airflow/contrib/operators/datastore_export_operator.py b/airflow/contrib/operators/datastore_export_operator.py index 15b19ecfb81a7..09b7965972384 100644 --- a/airflow/contrib/operators/datastore_export_operator.py +++ b/airflow/contrib/operators/datastore_export_operator.py @@ -19,6 +19,7 @@ # from airflow.contrib.hooks.datastore_hook import DatastoreHook from airflow.contrib.hooks.gcs_hook import GoogleCloudStorageHook +from airflow.exceptions import AirflowException from airflow.models import BaseOperator from airflow.utils.decorators import apply_defaults diff --git a/airflow/contrib/operators/datastore_import_operator.py b/airflow/contrib/operators/datastore_import_operator.py index 2c9c75eddc123..279b1a532e92a 100644 --- a/airflow/contrib/operators/datastore_import_operator.py +++ b/airflow/contrib/operators/datastore_import_operator.py @@ -18,6 +18,7 @@ # under the License. # from airflow.contrib.hooks.datastore_hook import DatastoreHook +from airflow.exceptions import AirflowException from airflow.models import BaseOperator from airflow.utils.decorators import apply_defaults @@ -88,11 +89,9 @@ def execute(self, context): result = ds_hook.poll_operation_until_done(operation_name, self.polling_interval_in_seconds) - state = result['metadata']['common']['state'] if state != 'SUCCESSFUL': raise AirflowException('Operation failed: result={}'.format(result)) if self.xcom_push: return result - diff --git a/airflow/contrib/sensors/qubole_sensor.py b/airflow/contrib/sensors/qubole_sensor.py index 2860f92496f23..4f00e5550b4ee 100644 --- a/airflow/contrib/sensors/qubole_sensor.py +++ b/airflow/contrib/sensors/qubole_sensor.py @@ -56,6 +56,7 @@ def __init__(self, data, qubole_conn_id="qubole_default", *args, **kwargs): super(QuboleSensor, self).__init__(*args, **kwargs) def poke(self, context): + global this # apache/incubator-airflow/pull/3297#issuecomment-385988083 conn = BaseHook.get_connection(self.qubole_conn_id) Qubole.configure(api_token=conn.password, api_url=conn.host) @@ -65,7 +66,7 @@ def poke(self, context): try: status = self.sensor_class.check(self.data) except Exception as e: - logging.exception(e) + this.log.exception(e) status = False this.log.info('Status of this Poke: %s', status) diff --git a/tests/operators/test_virtualenv_operator.py b/tests/operators/test_virtualenv_operator.py index b1d62e3452648..82abe9c8098de 100644 --- a/tests/operators/test_virtualenv_operator.py +++ b/tests/operators/test_virtualenv_operator.py @@ -163,6 +163,7 @@ def f(a): def test_string_args(self): def f(): + global virtualenv_string_args print(virtualenv_string_args) if virtualenv_string_args[0] != virtualenv_string_args[2]: raise Exception @@ -197,4 +198,3 @@ def test_context(self): def f(**kwargs): return kwargs['templates_dict']['ds'] self._run_as_operator(f, templates_dict={'ds': '{{ ds }}'}) -