diff options
author | imarom <imarom@cisco.com> | 2015-09-21 18:57:01 +0300 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2015-09-21 18:57:01 +0300 |
commit | 52e2ab74873d1958c0f7ab6e598a402fe0a673c5 (patch) | |
tree | 67b6a2e33c0fb5295f9ed97e76db9c456ffe7f00 /scripts/automation/trex_control_plane/client_utils | |
parent | 14006b519bfd679227a87d0e6a2be9726774aafc (diff) |
some minor fixes
Diffstat (limited to 'scripts/automation/trex_control_plane/client_utils')
-rw-r--r-- | scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py index aff3def5..8b091b5e 100644 --- a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py +++ b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py @@ -25,8 +25,7 @@ class BatchMessage(object): def add (self, method_name, params = {}): - id = self.rpc_client.id_gen.next() - msg = self.rpc_client.create_jsonrpc_v2(method_name, params, id) + id, msg = self.rpc_client.create_jsonrpc_v2(method_name, params, encode = False) self.batch_list.append(msg) def invoke (self, block = False): @@ -91,7 +90,7 @@ class JsonRpcClient(object): def create_batch (self): return BatchMessage(self) - def create_jsonrpc_v2 (self, method_name, params = {}): + def create_jsonrpc_v2 (self, method_name, params = {}, encode = True): msg = {} msg["jsonrpc"] = "2.0" msg["method"] = method_name @@ -100,7 +99,10 @@ class JsonRpcClient(object): msg["id"] = self.id_gen.next() - return id, json.dumps(msg) + if encode: + return id, json.dumps(msg) + else: + return id, msg def invoke_rpc_method (self, method_name, params = {}, block = False): @@ -109,7 +111,6 @@ class JsonRpcClient(object): id, msg = self.create_jsonrpc_v2(method_name, params) - msg = json.dumps(msg) return self.send_raw_msg(msg, block) |