From 83caef88e10d30e001506c3792852b42ad97e8ab Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvoborni@redhat.com>
Date: Mon, 12 Jan 2015 14:18:49 +0100
Subject: [PATCH] rpcclient: use json_encode_binary for verbose output
`json.dumps` is not able to process some IPA's object types and therefore requires to preprocess it with `json_encode_binary` call. This step was not used in rpcclient's verbose output.
https://fedorahosted.org/freeipa/ticket/4773
Reviewed-By: Martin Basti <mbasti@redhat.com>
---
ipalib/rpc.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/ipalib/rpc.py b/ipalib/rpc.py
index 806f6bb9adf004660c9cb285cf31b09a988afa93..05ef3143324b0f6d260678ad354464511f907eac 100644
--- a/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -967,6 +967,7 @@ class JSONServerProxy(object):
def __request(self, name, args):
payload = {'method': unicode(name), 'params': args, 'id': 0}
version = args[1].get('version', VERSION_WITHOUT_CAPABILITIES)
+ payload = json_encode_binary(payload, version)
if self.__verbose >= 2:
root_logger.info('Request: %s',
@@ -975,7 +976,7 @@ class JSONServerProxy(object):
response = self.__transport.request(
self.__host,
self.__handler,
- json.dumps(json_encode_binary(payload, version)),
+ json.dumps(payload),
verbose=self.__verbose >= 3,
)
@@ -985,8 +986,11 @@ class JSONServerProxy(object):
raise JSONError(str(e))
if self.__verbose >= 2:
- root_logger.info('Response: %s',
- json.dumps(response, sort_keys=True, indent=4))
+ root_logger.info(
+ 'Response: %s',
+ json.dumps(json_encode_binary(response, version),
+ sort_keys=True, indent=4)
+ )
error = response.get('error')
if error:
try:
--
2.1.0