@@ -26,13 +26,18 @@ def upload(dir):
2626 errors = {}
2727 success = False
2828
29- if not os .path .exists (secure_filename (dirname )):
30- os .makedirs (secure_filename (dirname ))
29+ cur_path = os .path .dirname (os .path .abspath (__file__ ))
30+ concore_path = os .path .abspath (os .path .join (cur_path , '../../' ))
31+ directory_name = os .path .abspath (os .path .join (concore_path , secure_filename (dirname )))
32+
33+ if not os .path .isdir (directory_name ):
34+ os .mkdir (directory_name )
35+
3136
3237 for file in files :
3338 if file :
3439 filename = secure_filename (file .filename )
35- file .save (secure_filename ( dirname ) + "/" + filename )
40+ file .save (directory_name + "/" + filename )
3641 success = True
3742
3843 if success and errors :
@@ -95,9 +100,11 @@ def execute(dir):
95100# to download /build/<dir>?fetch=<graphml>. For example, /build/test?fetch=sample1
96101@app .route ('/build/<dir>' , methods = ['POST' ])
97102def build (dir ):
98- graphml_file = request .args .get ('fetch' )
99- makestudy_dir = dir + "/" + graphml_file #for makestudy
100- cur_path = os .getcwd ()
103+ graphml_file = request .args .get ('fetch' )
104+ apikey = request .args .get ('apikey' )
105+ dirname = dir + "_" + apikey
106+ makestudy_dir = dirname + "/" + graphml_file #for makestudy
107+ cur_path = os .path .dirname (os .path .abspath (__file__ ))
101108 concore_path = os .path .abspath (os .path .join (cur_path , '../../' ))
102109 dir_path = os .path .abspath (os .path .join (concore_path , graphml_file )) #path for ./build
103110 if not os .path .exists (secure_filename (dir_path )):
@@ -114,12 +121,12 @@ def build(dir):
114121
115122@app .route ('/debug/<dir>' , methods = ['POST' ])
116123def debug (dir ):
117- cur_path = os .getcwd ( )
124+ cur_path = os .path . dirname ( os . path . abspath ( __file__ ) )
118125 concore_path = os .path .abspath (os .path .join (cur_path , '../../' ))
119126 dir_path = os .path .abspath (os .path .join (concore_path , dir ))
120127 proc = call (["./debug" ], cwd = dir_path )
121128 if (proc == 0 ):
122- resp = jsonify ({'message' : 'Close the pop window after obtaing result' })
129+ resp = jsonify ({'message' : 'Close the pop window after obtaining result' })
123130 resp .status_code = 201
124131 return resp
125132 else :
@@ -134,13 +141,18 @@ def download(dir):
134141 apikey = request .args .get ('apikey' )
135142 dirname = dir + "_" + apikey
136143
144+ cur_path = os .path .dirname (os .path .abspath (__file__ ))
145+ concore_path = os .path .abspath (os .path .join (cur_path , '../../' ))
146+ directory_name = os .path .abspath (os .path .join (concore_path , secure_filename (dirname )))
147+
148+
137149 if not os .path .exists (secure_filename (dirname )):
138150 resp = jsonify ({'message' : 'Directory not found' })
139151 resp .status_code = 400
140152 return resp
141153
142154 try :
143- return send_from_directory (secure_filename ( dirname ) , download_file , as_attachment = True )
155+ return send_from_directory (directory_name , download_file , as_attachment = True )
144156 except :
145157 resp = jsonify ({'message' : 'file not found' })
146158 resp .status_code = 400
@@ -149,7 +161,8 @@ def download(dir):
149161
150162@app .route ('/destroy/<dir>' , methods = ['DELETE' ])
151163def destroy (dir ):
152- cur_path = os .getcwd ()
164+ # cur_path = os.getcwd()
165+ cur_path = os .path .dirname (os .path .abspath (__file__ ))
153166 concore_path = os .path .abspath (os .path .join (cur_path , '../../' ))
154167 proc = call (["./destroy" , dir ], cwd = concore_path )
155168 if (proc == 0 ):
@@ -163,7 +176,8 @@ def destroy(dir):
163176
164177@app .route ('/getFilesList/<dir>' , methods = ['POST' ])
165178def getFilesList (dir ):
166- cur_path = os .getcwd ()
179+ # cur_path = os.getcwd()
180+ cur_path = os .path .dirname (os .path .abspath (__file__ ))
167181 concore_path = os .path .abspath (os .path .join (cur_path , '../../' ))
168182 dir_path = os .path .abspath (os .path .join (concore_path , dir ))
169183 res = []
@@ -174,7 +188,9 @@ def getFilesList(dir):
174188
175189@app .route ('/openJupyter/' , methods = ['POST' ])
176190def openJupyter ():
177- cur_path = os .getcwd ()
191+ # cur_path = os.getcwd()
192+ cur_path = os .path .dirname (os .path .abspath (__file__ ))
193+ print (cur_path )
178194 concore_path = os .path .abspath (os .path .join (cur_path , '../../' ))
179195 proc = subprocess .Popen (['jupyter' , 'lab' ], shell = False , stdout = subprocess .PIPE , cwd = concore_path )
180196 if proc .poll () is None :
0 commit comments