From ab4f0d570e1dfbad27b06d5cd22837e8e1e9c652 Mon Sep 17 00:00:00 2001 From: Rahul Date: Fri, 23 Jun 2023 01:09:03 +0530 Subject: [PATCH 1/3] docker, params, maxtime made accesible from concore-editor --- fri/server/main.py | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/fri/server/main.py b/fri/server/main.py index b2b790e..105a490 100644 --- a/fri/server/main.py +++ b/fri/server/main.py @@ -65,7 +65,10 @@ def upload(dir): # to download /build/?fetch=. For example, /build/test?fetch=sample1&apikey=xyz @app.route('/build/', methods=['POST']) def build(dir): - graphml_file = request.args.get('fetch') + graphml_file = request.args.get('fetch') + params = request.args.get('params') + docker = request.args.get('docker') + maxtime = request.args.get('maxtime') apikey = request.args.get('apikey') out_dir = request.args.get('outdir') if(apikey == None): @@ -80,14 +83,26 @@ def build(dir): if not os.path.exists(dir_path): if(platform.uname()[0]=='Windows'): if(out_dir == None or out_dir == ""): - proc= call(["makestudy", makestudy_dir], shell=True, cwd=concore_path) + if(docker == 'true'): + proc= call(["makedocker", makestudy_dir], shell=True, cwd=concore_path) + else: + proc= call(["makestudy", makestudy_dir], shell=True, cwd=concore_path) else: - proc= call(["makestudy", makestudy_dir, out_dir], shell=True, cwd=concore_path) + if(docker == 'true'): + proc= call(["makedocker", makestudy_dir, out_dir], shell=True, cwd=concore_path) + else: + proc= call(["makestudy", makestudy_dir, out_dir], shell=True, cwd=concore_path) else: if(out_dir == None or out_dir == ""): - proc= call(["./makestudy", makestudy_dir], cwd=concore_path) + if(docker == 'true'): + proc= call(["./makedocker", makestudy_dir], cwd=concore_path) + else: + proc= call(["./makestudy", makestudy_dir], cwd=concore_path) else: - proc= call(["./makestudy", makestudy_dir, out_dir], cwd=concore_path) + if(docker == 'true'): + proc= call(["./makedocker", makestudy_dir, out_dir], cwd=concore_path) + else: + proc= call(["./makestudy", makestudy_dir, out_dir], cwd=concore_path) if(proc == 0): resp = jsonify({'message': 'Directory successfully created'}) resp.status_code = 201 @@ -96,8 +111,16 @@ def build(dir): resp.status_code = 500 if(platform.uname()[0]=='Windows'): call(["build"], cwd=dir_path, shell=True) + if(maxtime != None and maxtime != ''): + proc=call(["maxtime", maxtime],shell=True, cwd=dir_path) + if(params != None and params != ''): + proc=call(["params", params],shell=True, cwd=dir_path) else: - call(["./build"], cwd=dir_path) + call(["./build"], cwd=dir_path) + if(maxtime != None and maxtime != ''): + proc=call(["./maxtime", maxtime], cwd=dir_path) + if(params != None and params != ''): + proc=call(["./params", params], cwd=dir_path) return resp @app.route('/debug/', methods=['POST']) @@ -154,12 +177,23 @@ def stop(dir): @app.route('/clear/', methods=['POST']) def clear(dir): + unlock = request.args.get('unlock') + params = request.args.get('params') + maxtime = request.args.get('maxtime') dir_name = secure_filename(dir) dir_path = os.path.abspath(os.path.join(concore_path, dir_name)) if(platform.uname()[0]=='Windows'): proc=call(["clear"],shell=True, cwd=dir_path) + if(maxtime != None and maxtime != ''): + proc=call(["maxtime", maxtime],shell=True, cwd=dir_path) + if(params != None and params != ''): + proc=call(["params", params],shell=True, cwd=dir_path) else: proc = call(["./clear"], cwd=dir_path) + if(maxtime != None and maxtime != ''): + proc=call(["./maxtime", maxtime], cwd=dir_path) + if(params != None and params != ''): + proc=call(["./params", params], cwd=dir_path) if(proc == 0): resp = jsonify({'message': 'result deleted'}) resp.status_code = 201 From 05dbeeed7e43402124518502ade82dd75b2ce9df Mon Sep 17 00:00:00 2001 From: Rahul Date: Fri, 23 Jun 2023 18:04:50 +0530 Subject: [PATCH 2/3] makedocker.bat added --- makedocker.bat | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 makedocker.bat diff --git a/makedocker.bat b/makedocker.bat new file mode 100644 index 0000000..b699c6c --- /dev/null +++ b/makedocker.bat @@ -0,0 +1,18 @@ +@echo off +if dummy%~n2 == dummy ( + if dummy%~x1 == dummy.graphml ( + echo python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n1 docker + python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n1 docker + ) else ( + echo python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n1 docker + python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n1 docker + ) +) else ( + if dummy%~x1 == dummy.graphml ( + echo python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n2 docker + python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n2 docker + ) else ( + echo python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n2 docker + python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n2 docker + ) +) \ No newline at end of file From 3a6c7cf75f1c798601cc3ded06585c9d6e16d106 Mon Sep 17 00:00:00 2001 From: Rahul Date: Sat, 24 Jun 2023 12:34:41 +0530 Subject: [PATCH 3/3] exec error solved for posix --- makedocker | 3 ++- makestudy | 2 ++ mkconcore.py | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/makedocker b/makedocker index ec84041..6e8041e 100755 --- a/makedocker +++ b/makedocker @@ -35,5 +35,6 @@ then echo "either do ./destroy $studydir, or choose a unique name as 2nd arg" else echo "python3 mkconcore.py $graphml $sourcedir $studydir docker" - python3 mkconcore.py $graphml $sourcedir $studydir docker + python3 mkconcore.py $graphml $sourcedir $studydir docker + chmod +x */* fi diff --git a/makestudy b/makestudy index 310de02..0e5c75e 100755 --- a/makestudy +++ b/makestudy @@ -39,8 +39,10 @@ else then echo "python3 mkconcore.py $graphml $sourcedir $studydir macos" python3 mkconcore.py $graphml $sourcedir $studydir macos + chmod +x */* else echo "python3 mkconcore.py $graphml $sourcedir $studydir ubuntu" python3 mkconcore.py $graphml $sourcedir $studydir ubuntu + chmod +x */* fi fi diff --git a/mkconcore.py b/mkconcore.py index 200771d..b5330a3 100644 --- a/mkconcore.py +++ b/mkconcore.py @@ -432,6 +432,7 @@ fcopy.write('CMD ["./a.out"]\n') # 7/02/21 fsource.close() + fbuild.write('#!/bin/bash' + "\n") for node in nodes_dict: containername,sourcecode = nodes_dict[node].split(':') if len(sourcecode)!=0 and sourcecode.find(".")!=-1: #3/28/21 @@ -462,6 +463,7 @@ fbuild.close() + frun.write('#!/bin/bash' + "\n") i=0 for node in nodes_dict: containername,sourcecode = nodes_dict[node].split(':') @@ -482,6 +484,7 @@ i=i+1 frun.close() + fstop.write('#!/bin/bash' + "\n") i=0 # 3/27/21 for node in nodes_dict: containername,sourcecode = nodes_dict[node].split(':') @@ -493,6 +496,7 @@ i=i+1 fstop.close() + fclear.write('#!/bin/bash' + "\n") i=0 # 9/13/21 for node in nodes_dict: containername,sourcecode = nodes_dict[node].split(':') @@ -505,6 +509,7 @@ i=i+1 fclear.close() + fmaxtime.write('#!/bin/bash' + "\n") fmaxtime.write('echo "$1" >concore.maxtime\n') fmaxtime.write('echo "FROM alpine:3.8" > Dockerfile\n') fmaxtime.write('sudo docker build -t docker-concore .\n') @@ -543,6 +548,7 @@ fmaxtime.write('rm concore.maxtime\n') fmaxtime.close() + fparams.write('#!/bin/bash' + "\n") fparams.write('echo "$1" >concore.params\n') fparams.write('echo "FROM alpine:3.8" > Dockerfile\n') fparams.write('sudo docker build -t docker-concore .\n') @@ -581,7 +587,7 @@ fparams.write('rm concore.params\n') fparams.close() - + funlock.write('#!/bin/bash' + "\n") funlock.write('echo "FROM alpine:3.8" > Dockerfile\n') funlock.write('sudo docker build -t docker-concore .\n') funlock.write('sudo docker run --name=concore') @@ -618,7 +624,7 @@ funlock.write('rm Dockerfile\n') funlock.close() - + fdebug.write('#!/bin/bash' + "\n") i=0 for node in nodes_dict: containername,sourcecode = nodes_dict[node].split(':') @@ -873,6 +879,8 @@ i=i+1 fmaxtime.close() +if concoretype=="posix": + fparams.write('#!/bin/bash' + "\n") i=0 # 9/18/22 for node in nodes_dict: containername,sourcecode = nodes_dict[node].split(':') @@ -888,7 +896,8 @@ i=i+1 fparams.close() - +if concoretype=="posix": + funlock.write('#!/bin/bash' + "\n") i=0 # 9/12/21 for node in nodes_dict: containername,sourcecode = nodes_dict[node].split(':')