Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions fri/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ def build(dir):
if(out_dir == None or out_dir == ""):
if(docker == 'true'):
try:
output_bytes = subprocess.check_output(["./makedocker", makestudy_dir], cwd=concore_path)
output_bytes = subprocess.check_output([r"./makedocker", makestudy_dir], cwd=concore_path)
output_str = output_bytes.decode("utf-8")
proc = 0
except subprocess.CalledProcessError as e:
output_str = f"Docker study creation failed with return code {e.returncode} (check duplicate directory)"
proc = 1
else:
try:
output_bytes = subprocess.check_output(["./makestudy", makestudy_dir], cwd=concore_path)
output_bytes = subprocess.check_output([r"./makestudy", makestudy_dir], cwd=concore_path)
output_str = output_bytes.decode("utf-8")
proc = 0
except subprocess.CalledProcessError as e:
Expand All @@ -166,15 +166,15 @@ def build(dir):
else:
if(docker == 'true'):
try:
output_bytes = subprocess.check_output(["./makedocker", makestudy_dir, out_dir], cwd=concore_path)
output_bytes = subprocess.check_output([r"./makedocker", makestudy_dir, out_dir], cwd=concore_path)
output_str = output_bytes.decode("utf-8")
proc = 0
except subprocess.CalledProcessError as e:
output_str = f"Docker study creation failed with return code {e.returncode} (check duplicate directory)"
proc = 1
else:
try:
output_bytes = subprocess.check_output(["./makestudy", makestudy_dir, out_dir], cwd=concore_path)
output_bytes = subprocess.check_output([r"./makestudy", makestudy_dir, out_dir], cwd=concore_path)
output_str = output_bytes.decode("utf-8")
proc = 0
except subprocess.CalledProcessError as e:
Expand All @@ -201,17 +201,17 @@ def build(dir):
proc=call(["params", params],shell=True, cwd=dir_path)
else:
try:
output_bytes = subprocess.check_output("./build", cwd=dir_path)
output_bytes = subprocess.check_output(r"./build", cwd=dir_path)
output_str = output_str + output_bytes.decode("utf-8")
resp = jsonify({'message': 'Directory successfully created', 'output': output_str})
except subprocess.CalledProcessError as e:
output_str = f"Build failed with return code {e.returncode}"
resp = jsonify({'message': 'Build Failed', 'output': output_str})
resp.status_code = 500
if(maxtime != None and maxtime != ''):
proc=call(["./maxtime", maxtime], cwd=dir_path)
proc=call([r"./maxtime", maxtime], cwd=dir_path)
if(params != None and params != ''):
proc=call(["./params", params], cwd=dir_path)
proc=call([r"./params", params], cwd=dir_path)
return resp

@app.route('/debug/<dir>', methods=['POST'])
Expand All @@ -221,7 +221,7 @@ def debug(dir):
if(platform.uname()[0]=='Windows'):
proc = call(["debug"],shell=True, cwd=dir_path)
else:
proc = call(["./debug"], cwd=dir_path)
proc = call([r"./debug"], cwd=dir_path)
if(proc == 0):
resp = jsonify({'message': 'Close the pop window after obtaining result'})
resp.status_code = 201
Expand All @@ -238,7 +238,7 @@ def run(dir):
if(platform.uname()[0]=='Windows'):
proc = call(["run"],shell=True, cwd=dir_path)
else:
proc = call(["./run"], cwd=dir_path)
proc = call([r"./run"], cwd=dir_path)
if(proc == 0):
resp = jsonify({'message': 'result prepared'})
resp.status_code = 201
Expand All @@ -255,7 +255,7 @@ def stop(dir):
if(platform.uname()[0]=='Windows'):
proc = call(["stop"],shell=True, cwd=dir_path)
else:
proc = call(["./stop"], cwd=dir_path)
proc = call([r"./stop"], cwd=dir_path)
if(proc == 0):
resp = jsonify({'message': 'resources cleaned'})
resp.status_code = 201
Expand All @@ -280,11 +280,11 @@ def clear(dir):
if(params != None and params != ''):
proc = call(["params", params],shell=True, cwd=dir_path)
else:
proc = call(["./clear"], cwd=dir_path)
proc = call([r"./clear"], cwd=dir_path)
if(maxtime != None and maxtime != ''):
proc = call(["./maxtime", maxtime], cwd=dir_path)
proc = call([r"./maxtime", maxtime], cwd=dir_path)
if(params != None and params != ''):
proc = call(["./params", params], cwd=dir_path)
proc = call([r"./params", params], cwd=dir_path)
if(proc == 0):
resp = jsonify({'message': 'result deleted'})
resp.status_code = 201
Expand All @@ -308,9 +308,9 @@ def contribute():
proc=check_output(["contribute",STUDY_NAME,STUDY_NAME_PATH,AUTHOR_NAME,BRANCH_NAME,PR_TITLE,PR_BODY],cwd=concore_path,shell=True)
else:
if len(BRANCH_NAME)==0:
proc = check_output(["./contribute",STUDY_NAME,STUDY_NAME_PATH,AUTHOR_NAME],cwd=concore_path)
proc = check_output([r"./contribute",STUDY_NAME,STUDY_NAME_PATH,AUTHOR_NAME],cwd=concore_path)
else:
proc = check_output(["./contribute",STUDY_NAME,STUDY_NAME_PATH,AUTHOR_NAME,BRANCH_NAME,PR_TITLE,PR_BODY],cwd=concore_path)
proc = check_output([r"./contribute",STUDY_NAME,STUDY_NAME_PATH,AUTHOR_NAME,BRANCH_NAME,PR_TITLE,PR_BODY],cwd=concore_path)
output_string = proc.decode()
status=200
if output_string.find("/pulls/")!=-1:
Expand Down Expand Up @@ -349,7 +349,7 @@ def destroy(dir):
if(platform.uname()[0]=='Windows'):
proc = call(["destroy", dir],shell=True, cwd=concore_path)
else:
proc = call(["./destroy", dir], cwd=concore_path)
proc = call([r"./destroy", dir], cwd=concore_path)
if(proc == 0):
resp = jsonify({'message': 'Successfuly deleted Dirctory'})
resp.status_code = 201
Expand All @@ -367,11 +367,11 @@ def library(dir):
library_path = request.args.get('path')
proc = 0
if (library_path == None or library_path == ''):
library_path = "../tools"
library_path = r"../tools"
if(platform.uname()[0]=='Windows'):
proc = subprocess.check_output(["..\library", library_path, filename],shell=True, cwd=dir_path)
proc = subprocess.check_output([r"..\library", library_path, filename],shell=True, cwd=dir_path)
else:
proc = subprocess.check_output(["../library", library_path, filename], cwd=dir_path)
proc = subprocess.check_output([r"../library", library_path, filename], cwd=dir_path)
if(proc != 0):
resp = jsonify({'message': proc.decode("utf-8")})
resp.status_code = 201
Expand Down
11 changes: 7 additions & 4 deletions fri/test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from cgi import test
import requests
import os
import urllib.request
import time

# function to test upload() method.

def upload(files):
url = "http://127.0.0.1:5000/upload/test?apikey=xyz"
payload={}
Expand Down Expand Up @@ -62,8 +60,13 @@ def openJupyter():

# function to test download() method.
def download(dir, subDir, fileName , apikey ):
url = "http://127.0.0.1:5000/download/"+dir+"?"+"fetchDir="+subDir+"&"+"fetch="+ fileName+"&"+"apikey="+apikey
urllib.request.urlretrieve(url, fileName)
url = "http://127.0.0.1:5000/download/" + dir + "?" + "fetchDir=" + subDir + "&" + "fetch=" + fileName + "&" + "apikey=" + apikey
response = requests.get(url)
if response.status_code == 200:
with open(fileName, 'wb') as f:
f.write(response.content)
else:
print(f"Failed to download: {response.status_code}, {response.text}")

# file list to be uploaded
cur_path = os.path.dirname(os.path.abspath(__file__))
Expand Down