mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-09 01:44:03 -07:00
Fix undefined variables, basestring usage, and some associated python3 issues
This commit is contained in:
parent
9f7b0dfc30
commit
225fa5d092
84 changed files with 652 additions and 963 deletions
|
@ -190,6 +190,11 @@ EXAMPLES = '''
|
|||
RETURN = ''' # '''
|
||||
|
||||
import datetime
|
||||
import json
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.urls import open_url
|
||||
|
||||
|
||||
def get_api_auth_headers(api_id, api_key, url, statuspage):
|
||||
|
@ -210,8 +215,8 @@ def get_api_auth_headers(api_id, api_key, url, statuspage):
|
|||
else:
|
||||
auth_headers = headers
|
||||
auth_content = data
|
||||
except:
|
||||
return 1, None, None, e
|
||||
except Exception as e:
|
||||
return 1, None, None, to_native(e)
|
||||
return 0, auth_headers, auth_content, None
|
||||
|
||||
|
||||
|
@ -320,9 +325,8 @@ def create_maintenance(auth_headers, url, statuspage, host_ids,
|
|||
|
||||
if data["status"]["error"] == "yes":
|
||||
return 1, None, data["status"]["message"]
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
return 1, None, str(e)
|
||||
except Exception as e:
|
||||
return 1, None, to_native(e)
|
||||
return 0, None, None
|
||||
|
||||
|
||||
|
@ -339,9 +343,8 @@ def delete_maintenance(auth_headers, url, statuspage, maintenance_id):
|
|||
data = json.loads(response.read())
|
||||
if data["status"]["error"] == "yes":
|
||||
return 1, None, "Invalid maintenance_id"
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
return 1, None, str(e)
|
||||
except Exception as e:
|
||||
return 1, None, to_native(e)
|
||||
return 0, None, None
|
||||
|
||||
|
||||
|
@ -475,7 +478,6 @@ def main():
|
|||
module.fail_json(
|
||||
msg="Failed to delete maintenance: %s" % error)
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.urls import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue