Fix linting errors; fix some real bugs (#5111)

* Fix linting errors.

* Fix bugs.

* Another linter error ignored.

* More fixes.

* Ignore sanity errors with older versions.

ci_complete

* Forgot to commit more changes.
This commit is contained in:
Felix Fontein 2022-08-12 11:07:30 +02:00 committed by GitHub
parent 0338eb7a7c
commit a54af8909c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 115 additions and 94 deletions

View file

@ -234,10 +234,11 @@ import json
try:
from requests import Request, Session
except ImportError:
HAS_ANOTHER_LIBRARY = False
ANOTHER_LIBRARY_IMPORT_ERROR = traceback.format_exc()
HAS_REQUESTS = False
REQUESTS_IMPORT_ERROR = traceback.format_exc()
else:
HAS_ANOTHER_LIBRARY = True
HAS_REQUESTS = True
REQUESTS_IMPORT_ERROR = None
def build_url(account, key, is_sandbox):
@ -262,7 +263,7 @@ def iterate_data(module, request_object):
request_object.url = base_url + '&page=' + str(page)
new_results = Session().send(request_object)
data = data + new_results.json()["data"]
return(data)
return data
else:
module.fail_json('API Call failed, check ID, key and sandbox values')
@ -306,11 +307,10 @@ def main():
params['api_key'],
params['sandbox'])
if not HAS_ANOTHER_LIBRARY:
# Needs: from ansible.module_utils.basic import missing_required_lib
if not HAS_REQUESTS:
module.exit_json(
msg=missing_required_lib('another_library'),
exception=ANOTHER_LIBRARY_IMPORT_ERROR)
msg=missing_required_lib('requests'),
exception=REQUESTS_IMPORT_ERROR)
# At minimum we need account and key
if params['account_id'] and params['api_key']: