Skip to content
Closed
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
23 changes: 15 additions & 8 deletions fri/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,26 @@ def build(dir):
makestudy_dir = dirname + "/" + graphml_file #for makestudy
dir_path = os.path.abspath(os.path.join(concore_path, graphml_file)) #path for ./build
if not os.path.exists(dir_path):
proc = call(["./makestudy", makestudy_dir], cwd=concore_path)
proc = call(["makestudy", makestudy_dir],shell=True, cwd=concore_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. So this fix should be repeated for all the methods (clear, run, ...) I believe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I will update soon

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

if(proc == 0):
resp = jsonify({'message': 'Directory successfully created'})
resp.status_code = 201
else:
resp = jsonify({'message': 'There is an Error'})
resp.status_code = 500
call(["./build"], cwd=dir_path)
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the PRs to be minimal. If you are addressing a bug, the PR should just address that, instead of making the logs more verbose, like here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I put an else block here as if
If block is not executed then resp object will not be defined and will give error , as resp object is only defined inside IF block

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha, sorry, my bad. You are right.

resp= jsonify({"message":"Success"})
resp.status_code=200
call(["build"],shell=True, cwd=dir_path)
return resp


# Give the directory of the build files that are build using ./build
@app.route('/debug/<dir>', methods=['POST'])
def debug(dir):
dir = secure_filename(dir)
dir_path = os.path.abspath(os.path.join(concore_path, dir))
proc = call(["./debug"], cwd=dir_path)
proc = call(["debug"],shell=True , cwd=dir_path)
if(proc == 0):
resp = jsonify({'message': 'Close the pop window after obtaining result'})
resp.status_code = 201
Expand All @@ -96,11 +100,13 @@ def debug(dir):
return resp


# Give the directory of the build files that are build using ./build
@app.route('/run/<dir>', methods=['POST'])
def run(dir):
dir = secure_filename(dir)
dir_path = os.path.abspath(os.path.join(concore_path, dir))
proc = call(["./run"], cwd=dir_path)
print(dir_path)
proc = call(["run"],shell=True, cwd=dir_path)
if(proc == 0):
resp = jsonify({'message': 'result prepared'})
resp.status_code = 201
Expand All @@ -110,11 +116,12 @@ def run(dir):
resp.status_code = 500
return resp

# Give the directory of the build files that are build using ./build
@app.route('/stop/<dir>', methods=['POST'])
def stop(dir):
dir = secure_filename(dir)
dir_path = os.path.abspath(os.path.join(concore_path, dir))
proc = call(["./stop"], cwd=dir_path)
proc = call(["stop"],shell=True, cwd=dir_path)
if(proc == 0):
resp = jsonify({'message': 'resources cleaned'})
resp.status_code = 201
Expand All @@ -129,7 +136,7 @@ def stop(dir):
def clear(dir):
dir = secure_filename(dir)
dir_path = os.path.abspath(os.path.join(concore_path, dir))
proc = call(["./clear"], cwd=dir_path)
proc = call(["clear"],shell=True, cwd=dir_path)
if(proc == 0):
resp = jsonify({'message': 'result deleted'})
resp.status_code = 201
Expand Down Expand Up @@ -161,7 +168,7 @@ def download(dir):
@app.route('/destroy/<dir>', methods=['DELETE'])
def destroy(dir):
dir = secure_filename(dir)
proc = call(["./destroy", dir], cwd=concore_path)
proc = call(["destroy", dir],shell=True, cwd=concore_path)
if(proc == 0):
resp = jsonify({'message': 'Successfuly deleted Dirctory'})
resp.status_code = 201
Expand All @@ -182,7 +189,7 @@ def getFilesList(dir):
return res


@app.route('/openJupyter/', methods=['POST'])
@app.route('/openJupyter', methods=['POST'])
def openJupyter():
proc = subprocess.Popen(['jupyter', 'lab'], shell=False, stdout=subprocess.PIPE, cwd=concore_path)
if proc.poll() is None:
Expand Down