Get hipchat, sns, and typetalk notification modules compiling on py3 (#2782)

This commit is contained in:
Toshio Kuratomi 2016-08-24 08:40:31 -07:00 committed by Matt Clay
commit 7a8b080506
4 changed files with 54 additions and 29 deletions

View file

@ -61,7 +61,7 @@ options:
required: false
aws_secret_key:
description:
- AWS secret key. If not set then the value of the AWS_SECRET_KEY environment variable is used.
- AWS secret key. If not set then the value of the AWS_SECRET_KEY environment variable is used.
required: false
default: None
aliases: ['ec2_secret_key', 'secret_key']
@ -77,7 +77,8 @@ options:
required: false
aliases: ['aws_region', 'ec2_region']
requirements: [ "boto" ]
requirements:
- "boto"
"""
EXAMPLES = """
@ -97,10 +98,14 @@ EXAMPLES = """
topic: "deploy"
"""
import sys
try:
import json
except ImportError:
import simplejson as json
from ansible.module_utils.basic import *
from ansible.module_utils.ec2 import *
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import ec2_argument_spec, connect_to_aws, get_aws_connection_info
from ansible.module_utils.pycompat24 import get_exception
try:
import boto
@ -156,7 +161,8 @@ def main():
module.fail_json(msg="region must be specified")
try:
connection = connect_to_aws(boto.sns, region, **aws_connect_params)
except boto.exception.NoAuthHandlerFound, e:
except boto.exception.NoAuthHandlerFound:
e = get_exception()
module.fail_json(msg=str(e))
# .publish() takes full ARN topic id, but I'm lazy and type shortnames
@ -185,9 +191,11 @@ def main():
try:
connection.publish(topic=arn_topic, subject=subject,
message_structure='json', message=json_msg)
except boto.exception.BotoServerError, e:
except boto.exception.BotoServerError:
e = get_exception()
module.fail_json(msg=str(e))
module.exit_json(msg="OK")
main()
if __name__ == '__main__':
main()