From 84f51f48a59da93e287d793d983ace4d06ccb483 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 4 Mar 2022 08:31:42 +0300 Subject: Automatically decode Redis strings --- gn3/api/async_commands.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'gn3/api') diff --git a/gn3/api/async_commands.py b/gn3/api/async_commands.py index f8400c8..81c3c44 100644 --- a/gn3/api/async_commands.py +++ b/gn3/api/async_commands.py @@ -8,14 +8,11 @@ async_commands = Blueprint("async_commands", __name__) @async_commands.route("/state/") def command_state(command_id): - with redis.Redis() as rconn: + with redis.Redis(decode_responses=True) as rconn: state = rconn.hgetall(name=command_id) if not state: return jsonify( status=404, error="The command id provided does not exist.") - state = { - key.decode("utf-8"): val.decode("utf8") - for key,val in state.items() - } + state = {key: val for key,val in state.items()} return jsonify(state) -- cgit v1.2.3