summaryrefslogtreecommitdiff
path: root/test/nagios/support
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-04-17 10:04:12 +0200
committerAzul <azul@leap.se>2014-04-17 10:39:59 +0200
commitd639e0a48599b30777b80c2809ded1efb3a6d926 (patch)
tree86fb496091a772cefd0e07d1558f6b7fe0636963 /test/nagios/support
parent36e99d8b23263cffcd58988c40ca3217349a94f2 (diff)
add a try/except for older versions of requests
they have response.json as a dict instead of response.json()
Diffstat (limited to 'test/nagios/support')
-rw-r--r--test/nagios/support/api.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/test/nagios/support/api.py b/test/nagios/support/api.py
index 3b6a90f..ec1af99 100644
--- a/test/nagios/support/api.py
+++ b/test/nagios/support/api.py
@@ -17,17 +17,23 @@ class Api():
response = self.session.get(self.api_url(path),
verify=self.verify,
**args)
- return response.json()
+ return self.parse_json(response)
def post(self, path, **args):
response = self.session.post(self.api_url(path),
verify=self.verify,
**args)
- return response.json()
+ return self.parse_json(response)
def put(self, path, **args):
response = self.session.put(self.api_url(path),
verify=self.verify,
**args)
- return response.json()
+ return self.parse_json(response)
+
+ def parse_json(self, response):
+ try:
+ return response.json()
+ except TypeError:
+ return response.json # older versions of requests