Convert URL output to a text/unicode string for json.loads
This commit is contained in:
parent
9ae95d52bc
commit
011c0d59cb
1 changed files with 4 additions and 1 deletions
|
@ -141,6 +141,7 @@ import string
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils._text import to_text
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
@ -183,8 +184,10 @@ def get_grafana_version(module, grafana_url, headers):
|
|||
r, info = fetch_url(module, '%s/api/frontend/settings' % grafana_url, headers=headers, method='GET')
|
||||
if info['status'] == 200:
|
||||
try:
|
||||
settings = json.loads(r.read())
|
||||
settings = json.loads(to_text(r.read()))
|
||||
grafana_version = settings['buildInfo']['version'].split('.')[0]
|
||||
except UnicodeError as e:
|
||||
raise GrafanaAPIException('Unable to decode version string to Unicode')
|
||||
except Exception as e:
|
||||
raise GrafanaAPIException(e)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue