44from subprocess import call
55from pathlib import Path
66import json
7+ import subprocess
78
89
910app = 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):
150151def 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' ])
175176def 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