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