From c6bce638cfac9df0a4f3f380971fde65b1947ad7 Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Tue, 5 Oct 2021 17:14:23 +0300 Subject: add socket obj and emit process --- gn3/computations/wgcna.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gn3/computations/wgcna.py b/gn3/computations/wgcna.py index 4dd0985..94e2a40 100644 --- a/gn3/computations/wgcna.py +++ b/gn3/computations/wgcna.py @@ -28,12 +28,18 @@ def stream_cmd_output(socket, cmd: str): """function to stream in realtime""" # xtodo syncing and closing /edge cases + socket.emit("output", {"data", f"calling you script {cmd}"}) + results = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) for line in iter(results.stdout.readline, b""): line = line.decode("utf-8").rstrip() - # xtodo emit the data + socket.emit("output", + {"data": line}) + # close above make sure the process is closed + + socket.emit("output", {"data": "parsing the output results"}) def process_image(image_loc: str) -> bytes: @@ -62,8 +68,6 @@ def call_wgcna_script(rscript_path: str, request_data: dict): run_cmd_results = run_cmd(cmd) - print(run_cmd_results["output"]) - with open(generated_file, "r") as outputfile: output_file_data = json.load(outputfile) -- cgit v1.2.3