diff options
author | imarom <imarom@cisco.com> | 2016-03-21 16:20:41 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-03-21 16:20:41 +0200 |
commit | c59a02f8036bbdc488f286412e990a16e3aa1df9 (patch) | |
tree | 510806f6e4dae8c6efd84e56974346d9c6677215 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py | |
parent | b89efa188810bf95a9d245e69e2961b5721c3b0f (diff) |
python 3 support - phase 2
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py')
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py index 1c783046..166fd64e 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py @@ -143,16 +143,21 @@ class JsonRpcClient(object): if self.logger.check_verbose(self.logger.VERBOSE_HIGH): self.verbose_msg("Sending Request To Server:\n\n" + self.pretty_json(msg) + "\n") - if len(msg) > self.MSG_COMPRESS_THRESHOLD: - response = self.send_raw_msg(self.compress_msg(msg)) + # encode string to buffer + buffer = msg.encode() + + if len(buffer) > self.MSG_COMPRESS_THRESHOLD: + response = self.send_raw_msg(self.compress_msg(buffer)) if response: response = self.decompress_msg(response) else: - response = self.send_raw_msg(msg) + response = self.send_raw_msg(buffer) if not response: return response + # return to string + response = response.decode() # print after if self.logger.check_verbose(self.logger.VERBOSE_HIGH): @@ -177,7 +182,7 @@ class JsonRpcClient(object): tries = 0 while True: try: - self.socket.send_string(msg) + self.socket.send(msg) break except zmq.Again: tries += 1 @@ -189,7 +194,7 @@ class JsonRpcClient(object): tries = 0 while True: try: - response = self.socket.recv_string() + response = self.socket.recv() break except zmq.Again: tries += 1 |