From ea9f2d5716c53fd35a7fb318e76a5da73cb32a3c Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 10 Mar 2021 12:52:41 +0300 Subject: Call Redis hset correctly in the right order --- gn3/commands.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/gn3/commands.py b/gn3/commands.py index 219f4fd..e5558fe 100644 --- a/gn3/commands.py +++ b/gn3/commands.py @@ -52,25 +52,18 @@ Returns the name of the specific redis hash for the specific task. unique_id = ("cmd::" f"{datetime.now().strftime('%Y-%m-%d%H-%M%S-%M%S-')}" f"{str(uuid4())}") - for key, value in {"cmd": cmd, - "result": "", - "status": "queued"}.items(): - conn.hset(key, value, unique_id) - conn.rpush(job_queue, - unique_id) + for key, value in {"cmd": cmd, "result": "", "status": "queued"}.items(): + conn.hset(name=unique_id, key=key, value=value) + conn.rpush(job_queue, unique_id) if email: - conn.hset("email", - email, - unique_id) + conn.hset(name=unique_id, key="email", value=email) return unique_id def run_cmd(cmd: str) -> Dict: """Run CMD and return the CMD's status code and output as a dict""" - results = subprocess.run(cmd, capture_output=True, - shell=True, check=False) + results = subprocess.run(cmd, capture_output=True, shell=True, check=False) out = str(results.stdout, 'utf-8') if results.returncode > 0: # Error! out = str(results.stderr, 'utf-8') - return {"code": results.returncode, - "output": out} + return {"code": results.returncode, "output": out} -- cgit v1.2.3