Commit 8f1b1d54 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Use explicitly json loads in kamaki client.

Do not treat None specially.
parent 4664c9ea
......@@ -106,7 +106,7 @@ class Callpoint(object):
data = None
data = self.make_call(call_name, data)
json_data = self.json_dumps(data) if data is not None else None
json_data = self.json_dumps(data)
return json_data
def make_call(self, call_name, data):
......@@ -27,8 +27,6 @@ def view(request, appname=None, version=None, callname=None):
body = _get_body(request)
body = callpoint.make_call_from_json(callname, body)
if body is None:
body = ''
status = 200
except Exception, e:
status = 450
......@@ -4,7 +4,7 @@ from commissioning import Callpoint, CallError
from commissioning.utils.debug import debug
from kamaki.clients import Client
from json import dumps as json_dumps
from json import loads as json_loads, dumps as json_dumps
class Kamaki_plugin(Callpoint):
......@@ -22,19 +22,20 @@ class Kamaki_plugin(Callpoint):
path = api_call
json_data = json_dumps(data)
debug("%s %s\n%s\n<<<\n", method, path, json_data)
debug("%s %s\n%s\n<<<\n", method.func_name, path, json_data)
resp = method(path, data=json_data)
debug(">>>\nStatus: %s", resp.status_code)
body = resp.text
debug("\n%s\n<<<\n", body[:128] if body else None)
status = int(resp.status_code)
if status == 200:
body = resp.json
debug("\n%s\n<<<\n", body[:128] if body else None)
return body
return json_loads(body)
error = resp.json()
error = json_loads(body)
except ValueError, e:
exc = CallError(body, call_error='ValueError')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment