From d031e3d12c2324165251e7e19103a92870adf9ad Mon Sep 17 00:00:00 2001 From: Rahul Date: Mon, 31 Jul 2023 00:34:16 +0530 Subject: [PATCH 1/2] library api created --- fri/server/main.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/fri/server/main.py b/fri/server/main.py index 82c4350..deae96c 100644 --- a/fri/server/main.py +++ b/fri/server/main.py @@ -347,6 +347,30 @@ def destroy(dir): resp = jsonify({'message': 'There is an Error'}) resp.status_code = 500 return resp + +@app.route('/library/', methods=['POST']) +def library(dir): + dir_name = secure_filename(dir) + dir_path = os.path.abspath(os.path.join(concore_path, dir_name)) + filename = request.args.get('filename') + library_path = request.args.get('path') + proc = 0 + if (library_path == None or library_path == ''): + library_path = "../tools" + if(platform.uname()[0]=='Windows'): + proc = subprocess.check_output(["..\library", library_path, filename],shell=True, cwd=dir_path) + else: + proc = subprocess.check_output(["../library", library_path, filename], cwd=dir_path) + if(proc != 0): + resp = jsonify({'message': proc.decode("utf-8")}) + resp.status_code = 201 + return resp + else: + resp = jsonify({'message': 'There is an Error'}) + resp.status_code = 500 + return resp + + @app.route('/getFilesList/', methods=['POST']) def getFilesList(dir): From d744a4602b922360ae4fd2e2ebeb9171c201ea5e Mon Sep 17 00:00:00 2001 From: Rahul Date: Mon, 31 Jul 2023 09:31:08 +0530 Subject: [PATCH 2/2] library modified --- fri/server/main.py | 20 -------------------- library | 3 ++- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/fri/server/main.py b/fri/server/main.py index deae96c..df04616 100644 --- a/fri/server/main.py +++ b/fri/server/main.py @@ -117,42 +117,34 @@ def build(dir): output_bytes = subprocess.check_output(["makedocker", makestudy_dir], cwd=concore_path, shell=True) output_str = output_bytes.decode("utf-8") proc = 0 - print(output_str) except subprocess.CalledProcessError as e: output_str = f"Docker study creation failed with return code {e.returncode} (check duplicate directory)" proc = 1 - print(output_str) else: try: output_bytes = subprocess.check_output(["makestudy", makestudy_dir], cwd=concore_path, shell=True) output_str = output_bytes.decode("utf-8") proc = 0 - print(output_str) except subprocess.CalledProcessError as e: output_str = f"Study creation failed with return code {e.returncode} (check duplicate directory)" proc = 1 - print(output_str) else: if(docker == 'true'): try: output_bytes = subprocess.check_output(["makedocker", makestudy_dir, out_dir], cwd=concore_path, shell=True) output_str = output_bytes.decode("utf-8") proc = 0 - print(output_str) except subprocess.CalledProcessError as e: output_str = f"Docker study creation failed with return code {e.returncode} (check duplicate directory)" proc = 1 - print(output_str) else: try: output_bytes = subprocess.check_output(["makestudy", makestudy_dir, out_dir], cwd=concore_path, shell=True) output_str = output_bytes.decode("utf-8") proc = 0 - print(output_str) except subprocess.CalledProcessError as e: output_str = f"Study creation failed with return code {e.returncode} (check duplicate directory)" proc = 1 - print(output_str) else: if(out_dir == None or out_dir == ""): if(docker == 'true'): @@ -160,42 +152,34 @@ def build(dir): output_bytes = subprocess.check_output(["./makedocker", makestudy_dir], cwd=concore_path) output_str = output_bytes.decode("utf-8") proc = 0 - print(output_str) except subprocess.CalledProcessError as e: output_str = f"Docker study creation failed with return code {e.returncode} (check duplicate directory)" proc = 1 - print(output_str) else: try: output_bytes = subprocess.check_output(["./makestudy", makestudy_dir], cwd=concore_path) output_str = output_bytes.decode("utf-8") proc = 0 - print(output_str) except subprocess.CalledProcessError as e: output_str = f"Study creation failed with return code {e.returncode} (check duplicate directory)" proc = 1 - print(output_str) else: if(docker == 'true'): try: output_bytes = subprocess.check_output(["./makedocker", makestudy_dir, out_dir], cwd=concore_path) output_str = output_bytes.decode("utf-8") proc = 0 - print(output_str) except subprocess.CalledProcessError as e: output_str = f"Docker study creation failed with return code {e.returncode} (check duplicate directory)" proc = 1 - print(output_str) else: try: output_bytes = subprocess.check_output(["./makestudy", makestudy_dir, out_dir], cwd=concore_path) output_str = output_bytes.decode("utf-8") proc = 0 - print(output_str) except subprocess.CalledProcessError as e: output_str = f"Study creation failed with return code {e.returncode} (check duplicate directory)" proc = 1 - print(output_str) if(proc == 0): resp = jsonify({'message': 'Directory successfully created'}) resp.status_code = 201 @@ -206,11 +190,9 @@ def build(dir): try: output_bytes = subprocess.check_output("build", cwd=dir_path, shell=True) output_str = output_str + output_bytes.decode("utf-8") - print(output_str) resp = jsonify({'message': 'Directory successfully created', 'output': output_str}) except subprocess.CalledProcessError as e: output_str = f"Build failed with return code {e.returncode}" - print(output_str) resp = jsonify({'message': 'Build Failed', 'output': output_str}) resp.status_code = 500 if(maxtime != None and maxtime != ''): @@ -221,11 +203,9 @@ def build(dir): try: output_bytes = subprocess.check_output("./build", cwd=dir_path) output_str = output_str + output_bytes.decode("utf-8") - print(output_str) resp = jsonify({'message': 'Directory successfully created', 'output': output_str}) except subprocess.CalledProcessError as e: output_str = f"Build failed with return code {e.returncode}" - print(output_str) resp = jsonify({'message': 'Build Failed', 'output': output_str}) resp.status_code = 500 if(maxtime != None and maxtime != ''): diff --git a/library b/library index 0d64dee..f00bfee 100755 --- a/library +++ b/library @@ -25,8 +25,9 @@ if [ $# = 0 ] if [ -e $tooldir/$filename ] then ln -s $tooldir/$filename $filename + echo "library link created" else - echo "$filename does not exist" + echo "$filename does not exist in $tooldir" fi else echo "$tooldir does not exist"