You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by sa...@apache.org on 2016/11/15 03:58:13 UTC

incubator-airflow git commit: Revert "[AIRFLOW-626] HTML Content does not show up when sending email with attachment"

Repository: incubator-airflow
Updated Branches:
  refs/heads/master 55af3e04f -> c6dd4d457


Revert "[AIRFLOW-626] HTML Content does not show up when sending email with attachment"

This reverts commit 55af3e04f8aa2062715370c8feec10308938715e.

Master is currently broken as shown on https://travis-ci.org/apache/incubator-airflow/jobs/175858834

======================================================================
FAIL: test_custom_backend (tests.EmailTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/apache/incubator-airflow/.tox/py27-cdh-airflow_backend_sqlite/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
    return func(*args, **keywargs)
  File "/home/travis/build/apache/incubator-airflow/tests/core.py", line 1927, in test_custom_backend
    send_email_test.assert_called_with('to', 'subject', 'content', files=None, dryrun=False, cc=None, bcc=None)
  File "/home/travis/build/apache/incubator-airflow/.tox/py27-cdh-airflow_backend_sqlite/lib/python2.7/site-packages/mock/mock.py", line 937, in assert_called_with
    six.raise_from(AssertionError(_error_message(cause)), cause)
  File "/home/travis/build/apache/incubator-airflow/.tox/py27-cdh-airflow_backend_sqlite/lib/python2.7/site-packages/six.py", line 718, in raise_from
    raise value
AssertionError: Expected call: mock('to', 'subject', 'content', bcc=None, cc=None, dryrun=False, files=None)
Actual call: mock('to', 'subject', 'content', bcc=None, cc=None, dryrun=False, files=None, mime_subtype=u'mixed')


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

Branch: refs/heads/master
Commit: c6dd4d4578918364da1cd3d5655a8d41a65871b5
Parents: 55af3e0
Author: Siddharth Anand <si...@yahoo.com>
Authored: Mon Nov 14 19:57:08 2016 -0800
Committer: Siddharth Anand <si...@yahoo.com>
Committed: Mon Nov 14 19:57:08 2016 -0800

----------------------------------------------------------------------
 airflow/operators/email_operator.py | 4 +---
 airflow/utils/email.py              | 8 ++++----
 2 files changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/c6dd4d45/airflow/operators/email_operator.py
----------------------------------------------------------------------
diff --git a/airflow/operators/email_operator.py b/airflow/operators/email_operator.py
index 5167a7a..76cc56b 100644
--- a/airflow/operators/email_operator.py
+++ b/airflow/operators/email_operator.py
@@ -49,7 +49,6 @@ class EmailOperator(BaseOperator):
             files=None,
             cc=None,
             bcc=None,
-            mime_subtype='mixed',
             *args, **kwargs):
         super(EmailOperator, self).__init__(*args, **kwargs)
         self.to = to
@@ -58,7 +57,6 @@ class EmailOperator(BaseOperator):
         self.files = files or []
         self.cc = cc
         self.bcc = bcc
-        self.mime_subtype = mime_subtype
 
     def execute(self, context):
-        send_email(self.to, self.subject, self.html_content, files=self.files, cc=self.cc, bcc=self.bcc, mime_subtype=self.mime_subtype)
+        send_email(self.to, self.subject, self.html_content, files=self.files, cc=self.cc, bcc=self.bcc)

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/c6dd4d45/airflow/utils/email.py
----------------------------------------------------------------------
diff --git a/airflow/utils/email.py b/airflow/utils/email.py
index c4906fd..6fe8662 100644
--- a/airflow/utils/email.py
+++ b/airflow/utils/email.py
@@ -33,17 +33,17 @@ from email.utils import formatdate
 from airflow import configuration
 
 
-def send_email(to, subject, html_content, files=None, dryrun=False, cc=None, bcc=None, mime_subtype='mixed'):
+def send_email(to, subject, html_content, files=None, dryrun=False, cc=None, bcc=None):
     """
     Send email using backend specified in EMAIL_BACKEND.
     """
     path, attr = configuration.get('email', 'EMAIL_BACKEND').rsplit('.', 1)
     module = importlib.import_module(path)
     backend = getattr(module, attr)
-    return backend(to, subject, html_content, files=files, dryrun=dryrun, cc=cc, bcc=bcc, mime_subtype=mime_subtype)
+    return backend(to, subject, html_content, files=files, dryrun=dryrun, cc=cc, bcc=bcc)
 
 
-def send_email_smtp(to, subject, html_content, files=None, dryrun=False, cc=None, bcc=None, mime_subtype='mixed'):
+def send_email_smtp(to, subject, html_content, files=None, dryrun=False, cc=None, bcc=None):
     """
     Send an email with html content
 
@@ -53,7 +53,7 @@ def send_email_smtp(to, subject, html_content, files=None, dryrun=False, cc=None
 
     to = get_email_address_list(to)
 
-    msg = MIMEMultipart(mime_subtype)
+    msg = MIMEMultipart('alternative')
     msg['Subject'] = subject
     msg['From'] = SMTP_MAIL_FROM
     msg['To'] = ", ".join(to)