1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix out-dated code style in new module logentries_msg.py

This commit is contained in:
Toshio Kuratomi 2018-01-04 20:50:42 -08:00
parent e9df2083a3
commit 6da06fac3f

View file

@ -1,22 +1,15 @@
#!/usr/bin/python #!/usr/bin/python
# This file is part of Ansible # Copyright 2017, Ansible Project
# #
# Ansible is free software: you can redistribute it and/or modify # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or from __future__ import absolute_import, division, print_function
# (at your option) any later version. __metaclass__ = type
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'status': ['preview'], ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community', 'supported_by': 'community',
'version': '1.0'} 'metadata_version': '1.1'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
@ -55,12 +48,10 @@ EXAMPLES = '''
msg="{{ ansible_hostname }}" msg="{{ ansible_hostname }}"
''' '''
# import module snippets
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.basic import AnsibleModule
import socket import socket
from ansible.module_utils.basic import AnsibleModule
def send_msg(module, token, msg, api, port): def send_msg(module, token, msg, api, port):
@ -73,8 +64,7 @@ def send_msg(module, token, msg, api, port):
try: try:
if not module.check_mode: if not module.check_mode:
s.send(message) s.send(message)
except: except Exception as e:
e = get_exception()
module.fail_json(msg="failed to send message, msg=%s" % e) module.fail_json(msg="failed to send message, msg=%s" % e)
s.close() s.close()
@ -98,8 +88,7 @@ def main():
try: try:
send_msg(module, token, msg, api, port) send_msg(module, token, msg, api, port)
changed = True changed = True
except Exception: except Exception as e:
e = get_exception()
module.fail_json(msg="unable to send msg: %s" % e) module.fail_json(msg="unable to send msg: %s" % e)
module.exit_json(changed=changed, msg=msg) module.exit_json(changed=changed, msg=msg)