diff options
author | BonfaceKilz | 2021-03-10 12:52:41 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-03-10 12:53:12 +0300 |
commit | ea9f2d5716c53fd35a7fb318e76a5da73cb32a3c (patch) | |
tree | b8278f748319c21dca17d4e2b0eed0b5d195e7f3 | |
parent | c1280700137390e98017f251ed26a0a656fa49d9 (diff) | |
download | genenetwork3-ea9f2d5716c53fd35a7fb318e76a5da73cb32a3c.tar.gz |
Call Redis hset correctly in the right order
-rw-r--r-- | gn3/commands.py | 19 |
1 files 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} |