diff --git a/fri/server/main.py b/fri/server/main.py
index 348f57a..ce48e22 100644
--- a/fri/server/main.py
+++ b/fri/server/main.py
@@ -1,7 +1,8 @@
+from asyncio import subprocess
from flask import Flask, request, jsonify, send_file, send_from_directory
from werkzeug.utils import secure_filename
import os
-from subprocess import call
+from subprocess import call, run, Popen
from pathlib import Path
@@ -47,6 +48,59 @@ def upload(dir):
resp.status_code = 500
return resp
+@app.route('/build/
', methods=['POST'])
+def build(dir):
+ makestudy_dir = "demo" + "/" + dir
+ cur_path = os.getcwd()
+ concore_path = os.path.abspath(os.path.join(cur_path, '../../'))
+ dir_path = os.path.abspath(os.path.join(concore_path, dir))
+ if not os.path.exists(secure_filename(dir_path)):
+ p1 = call(["./makestudy", makestudy_dir], cwd=concore_path)
+ if(p1 == 0):
+ resp = jsonify({'message': 'Directory successfully created'})
+ resp.status_code = 201
+ return resp
+ else:
+ resp = jsonify({'message': 'There is an Error'})
+ resp.status_code = 500
+ return resp
+ call(["./build"], cwd=dir_path)
+ return resp
+
+
+@app.route('/debug/', methods=['POST'])
+def debug(dir):
+ cur_path = os.getcwd()
+ concore_path = os.path.abspath(os.path.join(cur_path, '../../'))
+ dir_path = os.path.abspath(os.path.join(concore_path, dir))
+ p1 = call(["./debug"], cwd=dir_path)
+ if(p1 == 0):
+ resp = jsonify({'message': 'Close the pop window after obtaing result'})
+ resp.status_code = 201
+ return resp
+ else:
+ resp = jsonify({'message': 'There is an Error'})
+ resp.status_code = 500
+ return resp
+
+
+
+@app.route('/destroy/', methods=['POST'])
+def destroy(dir):
+ cur_path = os.getcwd()
+ concore_path = os.path.abspath(os.path.join(cur_path, '../../'))
+ p1 = call(["./destroy", dir], cwd=concore_path)
+ if(p1 == 0):
+ resp = jsonify({'message': 'Successfuly deleted Dirctory'})
+ resp.status_code = 201
+ return resp
+ else:
+ resp = jsonify({'message': 'There is an Error'})
+ resp.status_code = 500
+ return resp
+
+
+
# To execute any python file. For example, /execute/test?apikey=xyz
@app.route('/execute/', methods=['POST'])
def execute(dir):
diff --git a/mkconcore.py b/mkconcore.py
index 40aa885..4cb6ed5 100644
--- a/mkconcore.py
+++ b/mkconcore.py
@@ -10,11 +10,11 @@
GRAPHML_FILE = sys.argv[1]
TRIMMED_LOGS = True
CONCOREPATH = "."
-CPPWIN = "g++" #Windows C++ 6/22/21
-CPPEXE = "g++" #Ubuntu/macOS C++ 6/22/21
-VWIN = "iverilog" #Windows verilog 6/25/21
-VEXE = "iverilog" #Ubuntu/macOS verilog 6/25/21
-CPPEXE = "g++" #Ubuntu/macOS C++ 6/22/21
+CPPWIN = "g++" #Windows C++ 6/22/21
+CPPEXE = "g++" #Ubuntu/macOS C++ 6/22/21
+VWIN = "iverilog" #Windows verilog 6/25/21
+VEXE = "iverilog" #Ubuntu/macOS verilog 6/25/21
+CPPEXE = "g++" #Ubuntu/macOS C++ 6/22/21
PYTHONEXE = "python3" #Ubuntu/macOS python 3
PYTHONWIN = "python" #Windows python 3
MATLABEXE = "matlab" #Ubuntu/macOS matlab
@@ -22,26 +22,26 @@
OCTAVEEXE = "octave" #Ubuntu/macOS octave
OCTAVEWIN = "octave" #Windows octave
M_IS_OCTAVE = False #treat .m as octave
-MCRPATH = "~/MATLAB/R2021a" #path to local Ubunta Matlab Compiler Runtime
+MCRPATH = "~/MATLAB/R2021a" #path to local Ubunta Matlab Compiler Runtime
DOCKEREXE = "sudo docker"#assume simple docker install
DOCKEREPO = "markgarnold"#where pulls come from 3/28/21
INDIRNAME = ":/in"
OUTDIRNAME = ":/out"
-
-if os.path.exists(CONCOREPATH+"/concore.octave"):
- M_IS_OCTAVE = True #treat .m as octave 9/27/21
-
-if os.path.exists(CONCOREPATH+"/concore.mcr"): # 11/12/21
- MCRPATH = open(CONCOREPATH+"/concore.mcr", "r").readline().strip() #path to local Ubunta Matlab Compiler Runtime
-
-if os.path.exists(CONCOREPATH+"/concore.sudo"): # 12/04/21
- DOCKEREXE = open(CONCOREPATH+"/concore.sudo", "r").readline().strip() #to omit sudo in docker
-
-if os.path.exists(CONCOREPATH+"/concore.repo"): # 12/04/21
- DOCKEREPO = open(CONCOREPATH+"/concore.repo", "r").readline().strip() #docker id for repo
-
-
+
+if os.path.exists(CONCOREPATH+"/concore.octave"):
+ M_IS_OCTAVE = True #treat .m as octave 9/27/21
+
+if os.path.exists(CONCOREPATH+"/concore.mcr"): # 11/12/21
+ MCRPATH = open(CONCOREPATH+"/concore.mcr", "r").readline().strip() #path to local Ubunta Matlab Compiler Runtime
+
+if os.path.exists(CONCOREPATH+"/concore.sudo"): # 12/04/21
+ DOCKEREXE = open(CONCOREPATH+"/concore.sudo", "r").readline().strip() #to omit sudo in docker
+
+if os.path.exists(CONCOREPATH+"/concore.repo"): # 12/04/21
+ DOCKEREPO = open(CONCOREPATH+"/concore.repo", "r").readline().strip() #docker id for repo
+
+
prefixedgenode = ""
sourcedir = sys.argv[2]
outdir = sys.argv[3]
@@ -61,13 +61,13 @@
if not (concoretype in ["posix","windows","docker","macos","ubuntu"]):
print(" type must be posix (macos or ubuntu), windows, or docker")
quit()
-ubuntu = False #6/24/21
-if concoretype == "ubuntu":
- concoretype = "posix"
- ubuntu = True
-if concoretype == "macos":
- concoretype = "posix"
-
+ubuntu = False #6/24/21
+if concoretype == "ubuntu":
+ concoretype = "posix"
+ ubuntu = True
+if concoretype == "macos":
+ concoretype = "posix"
+
if os.path.exists(outdir):
print(outdir+" already exists")
print("if intended, remove or rename "+outdir+" first")
@@ -82,16 +82,16 @@
fdebug = open("debug.bat", "w")
fstop = open("stop.bat", "w") #3/27/21
fclear = open("clear.bat", "w")
- fmaxtime = open("maxtime.bat", "w") # 9/12/21
- funlock = open("unlock.bat", "w") # 12/4/21
+ fmaxtime = open("maxtime.bat", "w") # 9/12/21
+ funlock = open("unlock.bat", "w") # 12/4/21
else:
fbuild = open("build","w")
frun = open("run", "w")
fdebug = open("debug", "w")
fstop = open("stop", "w") #3/27/21
fclear = open("clear", "w")
- fmaxtime = open("maxtime", "w") # 9/12/21
- funlock = open("unlock", "w") # 12/4/21
+ fmaxtime = open("maxtime", "w") # 9/12/21
+ funlock = open("unlock", "w") # 12/4/21
os.mkdir("src")
os.chdir("..")
@@ -101,9 +101,9 @@
print("source directory: "+sourcedir)
print("output directory: "+outdir)
print("control core type: "+concoretype)
-print("treat .m as octave:"+str(M_IS_OCTAVE))
-print("MCR path: "+MCRPATH)
-print("Docker repository: "+DOCKEREPO)
+print("treat .m as octave:"+str(M_IS_OCTAVE))
+print("MCR path: "+MCRPATH)
+print("Docker repository: "+DOCKEREPO)
# Output in a preferred format.
if TRIMMED_LOGS:
@@ -238,7 +238,7 @@
fcopy.write(fsource.read())
fsource.close()
-#copy proper concore.hpp into /src 6/22/21
+#copy proper concore.hpp into /src 6/22/21
try:
if concoretype=="docker":
fsource = open(CONCOREPATH+"/concoredocker.hpp")
@@ -251,7 +251,7 @@
fcopy.write(fsource.read())
fsource.close()
-#copy proper concore.v into /src 6/25/21
+#copy proper concore.v into /src 6/25/21
try:
if concoretype=="docker":
fsource = open(CONCOREPATH+"/concoredocker.v")
@@ -276,7 +276,7 @@
os.chmod(outdir+"/src/mkcompile",stat.S_IRWXU)
#copy concore*.m into /src 4/2/21
-try: #maxtime in matlab 11/22/21
+try: #maxtime in matlab 11/22/21
fsource = open(CONCOREPATH+"/concore_default_maxtime.m")
except:
print(CONCOREPATH+" is not correct path to concore")
@@ -493,85 +493,85 @@
containername,sourcecode = nodes_dict[node].split(':')
if len(sourcecode)!=0:
dockername = sourcecode.split(".")[0] #3/28/21
- writeedges = volswr[i]
- while writeedges.find(":") != -1:
+ writeedges = volswr[i]
+ while writeedges.find(":") != -1:
fclear.write(DOCKEREXE+' volume rm ' +writeedges.split(":")[0].split("-v")[1]+"\n")
- writeedges = writeedges[writeedges.find(":")+1:]
+ writeedges = writeedges[writeedges.find(":")+1:]
i=i+1
fclear.close()
-
- 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')
- fmaxtime.write('sudo docker run --name=concore')
- # -v VCZ:/VCZ -v VPZ:/VPZ
+
+ 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')
+ fmaxtime.write('sudo docker run --name=concore')
+ # -v VCZ:/VCZ -v VPZ:/VPZ
i=0 # 9/12/21
for node in nodes_dict:
containername,sourcecode = nodes_dict[node].split(':')
if len(sourcecode)!=0:
dockername = sourcecode.split(".")[0] #3/28/21
- writeedges = volswr[i]
- while writeedges.find(":") != -1:
- fmaxtime.write(' -v ')
+ writeedges = volswr[i]
+ while writeedges.find(":") != -1:
+ fmaxtime.write(' -v ')
fmaxtime.write(writeedges.split(":")[0].split("-v ")[1]+":/")
fmaxtime.write(writeedges.split(":")[0].split("-v ")[1])
- writeedges = writeedges[writeedges.find(":")+1:]
+ writeedges = writeedges[writeedges.find(":")+1:]
i=i+1
- fmaxtime.write(' docker-concore >/dev/null &\n')
- fmaxtime.write('sleep 3\n') # 12/6/21
- fmaxtime.write('echo "copying concore.maxtime=$1"\n')
+ fmaxtime.write(' docker-concore >/dev/null &\n')
+ fmaxtime.write('sleep 3\n') # 12/6/21
+ fmaxtime.write('echo "copying concore.maxtime=$1"\n')
i=0 # 9/12/21
for node in nodes_dict:
containername,sourcecode = nodes_dict[node].split(':')
if len(sourcecode)!=0:
dockername = sourcecode.split(".")[0] #3/28/21
- writeedges = volswr[i]
- while writeedges.find(":") != -1:
- fmaxtime.write('sudo docker cp concore.maxtime concore:/')
+ writeedges = volswr[i]
+ while writeedges.find(":") != -1:
+ fmaxtime.write('sudo docker cp concore.maxtime concore:/')
fmaxtime.write(writeedges.split(":")[0].split("-v ")[1]+"/concore.maxtime\n")
- writeedges = writeedges[writeedges.find(":")+1:]
+ writeedges = writeedges[writeedges.find(":")+1:]
i=i+1
- fmaxtime.write('sudo docker stop concore \n')
- fmaxtime.write('sudo docker rm concore\n')
- fmaxtime.write('sudo docker rmi docker-concore\n')
- fmaxtime.write('rm Dockerfile\n')
- fmaxtime.write('rm concore.maxtime\n')
+ fmaxtime.write('sudo docker stop concore \n')
+ fmaxtime.write('sudo docker rm concore\n')
+ fmaxtime.write('sudo docker rmi docker-concore\n')
+ fmaxtime.write('rm Dockerfile\n')
+ fmaxtime.write('rm concore.maxtime\n')
fmaxtime.close()
- 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')
- # -v VCZ:/VCZ -v VPZ:/VPZ
+ 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')
+ # -v VCZ:/VCZ -v VPZ:/VPZ
i=0 # 9/12/21
for node in nodes_dict:
containername,sourcecode = nodes_dict[node].split(':')
if len(sourcecode)!=0:
dockername = sourcecode.split(".")[0] #3/28/21
- writeedges = volswr[i]
- while writeedges.find(":") != -1:
- funlock.write(' -v ')
+ writeedges = volswr[i]
+ while writeedges.find(":") != -1:
+ funlock.write(' -v ')
funlock.write(writeedges.split(":")[0].split("-v ")[1]+":/")
funlock.write(writeedges.split(":")[0].split("-v ")[1])
- writeedges = writeedges[writeedges.find(":")+1:]
+ writeedges = writeedges[writeedges.find(":")+1:]
i=i+1
- funlock.write(' docker-concore >/dev/null &\n')
- funlock.write('sleep 1\n')
- funlock.write('echo "copying concore.apikey"\n')
+ funlock.write(' docker-concore >/dev/null &\n')
+ funlock.write('sleep 1\n')
+ funlock.write('echo "copying concore.apikey"\n')
i=0 # 9/12/21
for node in nodes_dict:
containername,sourcecode = nodes_dict[node].split(':')
if len(sourcecode)!=0:
dockername = sourcecode.split(".")[0] #3/28/21
- writeedges = volswr[i]
- while writeedges.find(":") != -1:
- funlock.write('sudo docker cp ~/concore.apikey concore:/')
+ writeedges = volswr[i]
+ while writeedges.find(":") != -1:
+ funlock.write('sudo docker cp ~/concore.apikey concore:/')
funlock.write(writeedges.split(":")[0].split("-v ")[1]+"/concore.apikey\n")
- writeedges = writeedges[writeedges.find(":")+1:]
+ writeedges = writeedges[writeedges.find(":")+1:]
i=i+1
- funlock.write('sudo docker stop concore \n')
- funlock.write('sudo docker rm concore\n')
- funlock.write('sudo docker rmi docker-concore\n')
- funlock.write('rm Dockerfile\n')
+ funlock.write('sudo docker stop concore \n')
+ funlock.write('sudo docker rm concore\n')
+ funlock.write('sudo docker rmi docker-concore\n')
+ funlock.write('rm Dockerfile\n')
funlock.close()
@@ -595,6 +595,10 @@
#remaining code deals only with posix or windows
#copy sourcefiles from ./src into corresponding directories
+#chnages by me
+if concoretype == "posix":
+ fbuild.write('#!/bin/bash'+"\n")
+
for node in nodes_dict:
containername,sourcecode = nodes_dict[node].split(':')
if len(sourcecode)!=0:
@@ -607,9 +611,11 @@
fbuild.write("copy .\\src\\"+sourcecode+" .\\"+containername+"\\"+sourcecode+"\n")
if langext == "py":
fbuild.write("copy .\\src\\concore.py .\\" + containername + "\\concore.py\n")
- elif langext == "cpp":
# 6/22/21
+ elif langext == "cpp":
+ # 6/22/21
fbuild.write("copy .\\src\\concore.hpp .\\" + containername + "\\concore.hpp\n")
- elif langext == "v":
# 6/25/21
+ elif langext == "v":
+ # 6/25/21
fbuild.write("copy .\\src\\concore.v .\\" + containername + "\\concore.v\n")
elif langext == "m": # 4/2/21
fbuild.write("copy .\\src\\concore_*.m .\\" + containername + "\\\n")
@@ -676,6 +682,8 @@
i=i+1
#start running source in associated dirs (run and debug scripts)
+if concoretype=="posix":
+ fdebug.write('#!/bin/bash' + "\n")
i=0
for node in nodes_dict:
containername,sourcecode = nodes_dict[node].split(':')
@@ -719,54 +727,54 @@
else:
if langext=="py":
frun.write('(cd '+containername+";"+PYTHONEXE+" "+sourcecode+" >concoreout.txt&echo $!>concorepid)&\n")
- if ubuntu:
+ if ubuntu:
fdebug.write('concorewd=`pwd`\n')
fdebug.write('xterm -e bash -c "cd $concorewd/'+containername+";"+PYTHONEXE+" "+sourcecode+';bash"&\n')
- else:
+ else:
fdebug.write('concorewd=`pwd`\n')
fdebug.write('osascript -e "tell application \\"Terminal\\" to do script \\"cd $concorewd/'+containername+";"+PYTHONEXE+" "+sourcecode+'\\""\n')
elif langext=="cpp": # 6/22/21
frun.write('(cd '+containername+";"+CPPEXE+" "+sourcecode+";./a.out >concoreout.txt&echo $!>concorepid)&\n")
- if ubuntu:
+ if ubuntu:
fdebug.write('concorewd=`pwd`\n')
fdebug.write('xterm -e bash -c "cd $concorewd/'+containername+";"+CPPEXE+" "+sourcecode+';./a.out;bash"&\n')
- else:
+ else:
fdebug.write('concorewd=`pwd`\n')
fdebug.write('osascript -e "tell application \\"Terminal\\" to do script \\"cd $concorewd/'+containername+";"+CPPEXE+" "+sourcecode+';./a.out\\""\n')
elif langext=="v": # 6/25/21
frun.write('(cd '+containername+";"+VEXE+" "+sourcecode+";./a.out >concoreout.txt&echo $!>concorepid)&\n")
- if ubuntu:
+ if ubuntu:
fdebug.write('concorewd=`pwd`\n')
fdebug.write('xterm -e bash -c "cd $concorewd/'+containername+";"+VEXE+" "+sourcecode+';./a.out;bash"&\n')
- else:
+ else:
fdebug.write('concorewd=`pwd`\n')
fdebug.write('osascript -e "tell application \\"Terminal\\" to do script \\"cd $concorewd/'+containername+";"+VEXE+" "+sourcecode+';vvp a.out\\""\n')
elif langext=="sh": # 5/19/21
frun.write('(cd '+containername+";./"+sourcecode+" "+ MCRPATH + " >concoreout.txt&echo $!>concorepid)&\n")
- if ubuntu:
+ if ubuntu:
fdebug.write('concorewd=`pwd`\n')
fdebug.write('xterm -e bash -c "cd $concorewd/'+containername+";./"+sourcecode+' '+MCRPATH+';bash"&\n')
- else: # 11/23/21 MCRPATH
+ else: # 11/23/21 MCRPATH
fdebug.write('concorewd=`pwd`\n')
fdebug.write('osascript -e "tell application \\"Terminal\\" to do script \\"cd $concorewd/'+containername+";./"+sourcecode+' '+MCRPATH+'\\""\n')
elif langext=="m": #3/23/21
if M_IS_OCTAVE:
frun.write('(cd '+containername+";"+ OCTAVEEXE+' -qf --eval run\\(\\'+"'"+sourcecode+"\\'"+'\\)'+" >concoreout.txt&echo $!>concorepid)&\n")
- if ubuntu:
+ if ubuntu:
fdebug.write('concorewd=`pwd`\n')
fdebug.write('xterm -e bash -c "cd $concorewd/'+containername+";"+OCTAVEEXE+' -qf --eval run\\(\\'+"'"+sourcecode+"\\'"+'\\);bash"&'+"\n")
- else:
+ else:
fdebug.write('concorewd=`pwd`\n')
fdebug.write('osascript -e "tell application \\"Terminal\\" to do script \\"cd $concorewd/'+containername+";"+OCTAVEEXE+' -qf --eval run\\\\\\(\\\\\\'+"'"+sourcecode+"\\\\\\'"+'\\\\\\)\\""'+"\n")
else: # 4/2/21
- frun.write('(cd '
+ frun.write('(cd '
+containername+";"+ MATLABEXE+' -batch run\\(\\'+"'"+sourcecode+"\\'"+'\\)'+" >concoreout.txt&echo $!>concorepid)&\n")
- if ubuntu:
+ if ubuntu:
fdebug.write('concorewd=`pwd`\n')
- fdebug.write('xterm -e bash -c "cd $concorewd/' +containername+";"+ MATLABEXE+' -batch run\\(\\'+"'"+sourcecode+"\\'"+'\\);bash"&\n' )
- else:
+ fdebug.write('xterm -e bash -c "cd $concorewd/' +containername+";"+ MATLABEXE+' -batch run\\(\\'+"'"+sourcecode+"\\'"+'\\);bash"&\n' )
+ else:
fdebug.write('concorewd=`pwd`\n')
- fdebug.write('osascript -e "tell application \\"Terminal\\" to do script \\"cd $concorewd/' +containername+";"+ MATLABEXE+' -batch run\\\\\\(\\\\\\'+"'"+sourcecode+"\\\\\\'"+'\\\\\\)\\""\n' )
+ fdebug.write('osascript -e "tell application \\"Terminal\\" to do script \\"cd $concorewd/' +containername+";"+ MATLABEXE+' -batch run\\\\\\(\\\\\\'+"'"+sourcecode+"\\\\\\'"+'\\\\\\)\\""\n' )
i=0 # 3/30/21
for node in nodes_dict:
@@ -787,13 +795,13 @@
containername,sourcecode = nodes_dict[node].split(':')
if len(sourcecode)!=0:
dockername = sourcecode.split(".")[0] #3/28/21
- writeedges = volswr[i]
- while writeedges.find(":") != -1:
+ writeedges = volswr[i]
+ while writeedges.find(":") != -1:
if concoretype=="windows":
fclear.write('del /Q' + writeedges.split(":")[0].split("-v")[1]+ "\\*\n")
else:
fclear.write('rm ' + writeedges.split(":")[0].split("-v")[1]+ "/*\n")
- writeedges = writeedges[writeedges.find(":")+1:]
+ writeedges = writeedges[writeedges.find(":")+1:]
i=i+1
fclear.close()
@@ -802,13 +810,13 @@
containername,sourcecode = nodes_dict[node].split(':')
if len(sourcecode)!=0:
dockername = sourcecode.split(".")[0] #3/28/21
- writeedges = volswr[i]
- while writeedges.find(":") != -1:
+ writeedges = volswr[i]
+ while writeedges.find(":") != -1:
if concoretype=="windows":
fmaxtime.write('echo %1 >' + writeedges.split(":")[0].split("-v")[1]+ "\\concore.maxtime\n")
else:
fmaxtime.write('echo "$1" >' + writeedges.split(":")[0].split("-v")[1]+ "/concore.maxtime\n")
- writeedges = writeedges[writeedges.find(":")+1:]
+ writeedges = writeedges[writeedges.find(":")+1:]
i=i+1
fmaxtime.close()
@@ -817,13 +825,13 @@
containername,sourcecode = nodes_dict[node].split(':')
if len(sourcecode)!=0:
dockername = sourcecode.split(".")[0] #3/28/21
- writeedges = volswr[i]
- while writeedges.find(":") != -1:
+ writeedges = volswr[i]
+ while writeedges.find(":") != -1:
if concoretype=="windows":
funlock.write('copy %HOMEDRIVE%%HOMEPATH%\concore.apikey' + writeedges.split(":")[0].split("-v")[1]+ "\\concore.apikey\n")
else:
funlock.write('cp ~/concore.apikey ' + writeedges.split(":")[0].split("-v")[1]+ "/concore.apikey\n")
- writeedges = writeedges[writeedges.find(":")+1:]
+ writeedges = writeedges[writeedges.find(":")+1:]
i=i+1
funlock.close()