From 6da06fac3f6067d7fff601e88576bbcfb4d9684d Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 4 Jan 2018 20:50:42 -0800 Subject: [PATCH] Fix out-dated code style in new module logentries_msg.py --- .../modules/notification/logentries_msg.py | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/lib/ansible/modules/notification/logentries_msg.py b/lib/ansible/modules/notification/logentries_msg.py index 78ac3f21a3..3407e0cf30 100755 --- a/lib/ansible/modules/notification/logentries_msg.py +++ b/lib/ansible/modules/notification/logentries_msg.py @@ -1,22 +1,15 @@ #!/usr/bin/python -# This file is part of Ansible +# Copyright 2017, Ansible Project # -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# 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 . +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', - 'version': '1.0'} + 'metadata_version': '1.1'} DOCUMENTATION = ''' --- @@ -55,12 +48,10 @@ EXAMPLES = ''' msg="{{ ansible_hostname }}" ''' - -# import module snippets -from ansible.module_utils.pycompat24 import get_exception -from ansible.module_utils.basic import AnsibleModule import socket +from ansible.module_utils.basic import AnsibleModule + def send_msg(module, token, msg, api, port): @@ -73,8 +64,7 @@ def send_msg(module, token, msg, api, port): try: if not module.check_mode: s.send(message) - except: - e = get_exception() + except Exception as e: module.fail_json(msg="failed to send message, msg=%s" % e) s.close() @@ -98,8 +88,7 @@ def main(): try: send_msg(module, token, msg, api, port) changed = True - except Exception: - e = get_exception() + except Exception as e: module.fail_json(msg="unable to send msg: %s" % e) module.exit_json(changed=changed, msg=msg)