summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Scherer <misc@zarb.org>2016-10-16 09:58:19 +0200
committerToshio Kuratomi <a.badger@gmail.com>2016-10-17 13:23:43 -0700
commit6b87e2f0d8a8baa91b74aa6cc321aecf3c019844 (patch)
treefd75065e02cf8ad95198b1b65ca2a5651ee802c4
parentf2ce143609d8eb2af9b3d8f6f89f7dd4ea68eb22 (diff)
downloadansible-modules-extras-6b87e2f0d8a8baa91b74aa6cc321aecf3c019844.tar.gz
Make mail compile on python 3
-rw-r--r--notification/mail.py10
-rw-r--r--test/utils/shippable/sanity-skip-python3.txt1
2 files changed, 7 insertions, 4 deletions
diff --git a/notification/mail.py b/notification/mail.py
index c8b2bb30..cdd5354b 100644
--- a/notification/mail.py
+++ b/notification/mail.py
@@ -218,7 +218,8 @@ def main():
smtp = smtplib.SMTP_SSL(host, port=int(port))
except (smtplib.SMTPException, ssl.SSLError):
smtp = smtplib.SMTP(host, port=int(port))
- except Exception, e:
+ except Exception:
+ e = get_exception()
module.fail_json(rc=1, msg='Failed to send mail to server %s on port %s: %s' % (host, port, e))
smtp.ehlo()
@@ -283,14 +284,16 @@ def main():
part.add_header('Content-disposition', 'attachment', filename=os.path.basename(file))
msg.attach(part)
- except Exception, e:
+ except Exception:
+ e = get_exception()
module.fail_json(rc=1, msg="Failed to send mail: can't attach file %s: %s" % (file, e))
composed = msg.as_string()
try:
smtp.sendmail(sender_addr, set(addr_list), composed)
- except Exception, e:
+ except Exception:
+ e = get_exception()
module.fail_json(rc=1, msg='Failed to send mail to %s: %s' % (", ".join(addr_list), e))
smtp.quit()
@@ -299,4 +302,5 @@ def main():
# import module snippets
from ansible.module_utils.basic import *
+from ansible.module_utils.pycompat24 import get_exception
main()
diff --git a/test/utils/shippable/sanity-skip-python3.txt b/test/utils/shippable/sanity-skip-python3.txt
index 0738f1e5..24f1bbbc 100644
--- a/test/utils/shippable/sanity-skip-python3.txt
+++ b/test/utils/shippable/sanity-skip-python3.txt
@@ -59,4 +59,3 @@
/network/openvswitch_bridge.py
/network/openvswitch_port.py
/notification/jabber.py
-/notification/mail.py