Skip to content

Commit 895b2ca

Browse files
authored
Merge pull request #15 from amit-62/dev1
updated openJupyter
2 parents b43a06f + 07023d8 commit 895b2ca

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

fri/server/main.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from subprocess import call
55
from pathlib import Path
66
import json
7+
import subprocess
78

89

910
app = Flask(__name__)
@@ -100,8 +101,8 @@ def build(dir):
100101
concore_path = os.path.abspath(os.path.join(cur_path, '../../'))
101102
dir_path = os.path.abspath(os.path.join(concore_path, graphml_file)) #path for ./build
102103
if not os.path.exists(secure_filename(dir_path)):
103-
p1 = call(["./makestudy", makestudy_dir], cwd=concore_path)
104-
if(p1 == 0):
104+
proc = call(["./makestudy", makestudy_dir], cwd=concore_path)
105+
if(proc == 0):
105106
resp = jsonify({'message': 'Directory successfully created'})
106107
resp.status_code = 201
107108
else:
@@ -116,8 +117,8 @@ def debug(dir):
116117
cur_path = os.getcwd()
117118
concore_path = os.path.abspath(os.path.join(cur_path, '../../'))
118119
dir_path = os.path.abspath(os.path.join(concore_path, dir))
119-
p1 = call(["./debug"], cwd=dir_path)
120-
if(p1 == 0):
120+
proc = call(["./debug"], cwd=dir_path)
121+
if(proc == 0):
121122
resp = jsonify({'message': 'Close the pop window after obtaing result'})
122123
resp.status_code = 201
123124
return resp
@@ -150,8 +151,8 @@ def download(dir):
150151
def destroy(dir):
151152
cur_path = os.getcwd()
152153
concore_path = os.path.abspath(os.path.join(cur_path, '../../'))
153-
p1 = call(["./destroy", dir], cwd=concore_path)
154-
if(p1 == 0):
154+
proc = call(["./destroy", dir], cwd=concore_path)
155+
if(proc == 0):
155156
resp = jsonify({'message': 'Successfuly deleted Dirctory'})
156157
resp.status_code = 201
157158
return resp
@@ -167,16 +168,23 @@ def getFilesList(dir):
167168
dir_path = os.path.abspath(os.path.join(concore_path, dir))
168169
res = []
169170
res = os.listdir(dir_path)
170-
res2 = json.dumps(res)
171-
return res2
171+
res = json.dumps(res)
172+
return res
172173

173174

174175
@app.route('/openJupyter/', methods=['POST'])
175176
def openJupyter():
176177
cur_path = os.getcwd()
177178
concore_path = os.path.abspath(os.path.join(cur_path, '../../'))
178-
p = call(["jupyter", "lab"], cwd=concore_path)
179-
return p
179+
proc = subprocess.Popen(['jupyter', 'lab'], shell=False, stdout=subprocess.PIPE, cwd=concore_path)
180+
if proc.poll() is None:
181+
resp = jsonify({'message': 'Successfuly opened Jupyter'})
182+
resp.status_code = 308
183+
return resp
184+
else:
185+
resp = jsonify({'message': 'There is an Error'})
186+
resp.status_code = 500
187+
return resp
180188

181189

182190

0 commit comments

Comments
 (0)