mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Do not use str() on exceptions (#46950)
This commit is contained in:
parent
2436aa1a4e
commit
a80c25cbd9
30 changed files with 76 additions and 66 deletions
|
@ -65,7 +65,7 @@ import os
|
|||
from ansible.errors import AnsibleError, AnsibleParserError
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.module_utils.urls import open_url
|
||||
from ansible.module_utils._text import to_bytes
|
||||
from ansible.module_utils._text import to_bytes, to_native
|
||||
from ansible.module_utils.six.moves.urllib.error import HTTPError
|
||||
|
||||
try:
|
||||
|
@ -118,7 +118,7 @@ class GrafanaAPI:
|
|||
try:
|
||||
r = open_url('%s/api/user/using/%s' % (self.grafana_url, self.grafana_org_id), headers=headers, method='POST')
|
||||
except HTTPError as e:
|
||||
raise GrafanaAPIException('Unable to switch to organization %s : %s' % (self.grafana_org_id, str(e)))
|
||||
raise GrafanaAPIException('Unable to switch to organization %s : %s' % (self.grafana_org_id, to_native(e)))
|
||||
if r.getcode() != 200:
|
||||
raise GrafanaAPIException('Unable to switch to organization %s : %s' % (self.grafana_org_id, str(r.getcode())))
|
||||
|
||||
|
@ -144,12 +144,12 @@ class GrafanaAPI:
|
|||
else:
|
||||
r = open_url('%s/api/search/' % self.grafana_url, headers=headers, method='GET')
|
||||
except HTTPError as e:
|
||||
raise GrafanaAPIException('Unable to search dashboards : %s' % str(e))
|
||||
raise GrafanaAPIException('Unable to search dashboards : %s' % to_native(e))
|
||||
if r.getcode() == 200:
|
||||
try:
|
||||
dashboard_list = json.loads(r.read())
|
||||
except Exception as e:
|
||||
raise GrafanaAPIException('Unable to parse json list %s' % str(e))
|
||||
raise GrafanaAPIException('Unable to parse json list %s' % to_native(e))
|
||||
else:
|
||||
raise GrafanaAPIException('Unable to list grafana dashboards : %s' % str(r.getcode()))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue