Skip to content

Commit

Permalink
Decode byte encoded response from redis before printing (#71)
Browse files Browse the repository at this point in the history
* Decode byte encoded response from redis before printing
In py3, the response from redis connector is encoded as byte array. They
need to be decoded before accessing them as strings.
* Always decode byte responses from redis
  • Loading branch information
rajendra-dendukuri committed May 24, 2020
1 parent 03748ce commit 9fab729
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/swsssdk/scripts/sonic-db-cli
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ def handle_all_instances(namespace, op, use_unix_socket=False):
def execute_cmd(dbname, cmd, namespace, use_unix_socket=False):
if namespace is None:
if use_unix_socket:
dbconn = swsssdk.SonicV2Connector(use_unix_socket_path=True)
dbconn = swsssdk.SonicV2Connector(use_unix_socket_path=True, decode_responses=True)
else:
dbconn = swsssdk.SonicV2Connector(use_unix_socket_path=False)
dbconn = swsssdk.SonicV2Connector(use_unix_socket_path=False, decode_responses=True)
else:
dbconn = swsssdk.SonicV2Connector(use_unix_socket_path=True, namespace=namespace)
dbconn = swsssdk.SonicV2Connector(use_unix_socket_path=True, namespace=namespace, decode_responses=True)
try:
dbconn.connect(dbname)
except RuntimeError:
Expand Down

0 comments on commit 9fab729

Please sign in to comment.