diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index 7815d250..044cec95 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -239,6 +239,9 @@ def print_result(res): if 'errorcode' in res or 'error' in res: print res['error'] return + if 'databynode' in res: + print_result(res['databynode']) + return for key in res.iterkeys(): notes = [] if res[key] is None: diff --git a/confluent_client/confluent/client.py b/confluent_client/confluent/client.py index c16f108c..1e819aca 100644 --- a/confluent_client/confluent/client.py +++ b/confluent_client/confluent/client.py @@ -71,12 +71,15 @@ class Command(object): self.authenticated = True def handle_results(self, ikey, rc, res): - if 'error' in res and type(res['error']) in (str, unicode): + if 'error' in res: sys.stderr.write('Error: {0}\n'.format(res['error'])) if 'errorcode' in res: return res['errorcode'] else: return 1 + if 'databynode' not in res: + return 0 + res = res['databynode'] for node in res: if 'error' in res[node]: sys.stderr.write('{0}: Error: {1}\n'.format( diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index b330ef04..5c7617b1 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -54,14 +54,20 @@ class ConfluentMessage(object): def json(self): # This will create the canonical json representation of this message - jsonsnippet = json.dumps(self.kvpairs, separators=(',', ':'))[1:-1] + if self.stripped: + datasource = self.kvpairs + else: + datasource = {'databynode': self.kvpairs} + jsonsnippet = json.dumps(datasource, separators=(',', ':'))[1:-1] return jsonsnippet def raw(self): """Return pythonic representation of the response. Used by httpapi while assembling data prior to json serialization""" - return self.kvpairs + if self.stripped: + return self.kvpairs + return {'databynode': self.kvpairs} def strip_node(self, node): self.stripped = True