Skip to content

Commit 1091829

Browse files
authored
Merge pull request #94 from Rahuljagwani/octave
Symbolic Link Implementation
2 parents a1d7477 + d744a46 commit 1091829

2 files changed

Lines changed: 26 additions & 21 deletions

File tree

fri/server/main.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -117,85 +117,69 @@ def build(dir):
117117
output_bytes = subprocess.check_output(["makedocker", makestudy_dir], cwd=concore_path, shell=True)
118118
output_str = output_bytes.decode("utf-8")
119119
proc = 0
120-
print(output_str)
121120
except subprocess.CalledProcessError as e:
122121
output_str = f"Docker study creation failed with return code {e.returncode} (check duplicate directory)"
123122
proc = 1
124-
print(output_str)
125123
else:
126124
try:
127125
output_bytes = subprocess.check_output(["makestudy", makestudy_dir], cwd=concore_path, shell=True)
128126
output_str = output_bytes.decode("utf-8")
129127
proc = 0
130-
print(output_str)
131128
except subprocess.CalledProcessError as e:
132129
output_str = f"Study creation failed with return code {e.returncode} (check duplicate directory)"
133130
proc = 1
134-
print(output_str)
135131
else:
136132
if(docker == 'true'):
137133
try:
138134
output_bytes = subprocess.check_output(["makedocker", makestudy_dir, out_dir], cwd=concore_path, shell=True)
139135
output_str = output_bytes.decode("utf-8")
140136
proc = 0
141-
print(output_str)
142137
except subprocess.CalledProcessError as e:
143138
output_str = f"Docker study creation failed with return code {e.returncode} (check duplicate directory)"
144139
proc = 1
145-
print(output_str)
146140
else:
147141
try:
148142
output_bytes = subprocess.check_output(["makestudy", makestudy_dir, out_dir], cwd=concore_path, shell=True)
149143
output_str = output_bytes.decode("utf-8")
150144
proc = 0
151-
print(output_str)
152145
except subprocess.CalledProcessError as e:
153146
output_str = f"Study creation failed with return code {e.returncode} (check duplicate directory)"
154147
proc = 1
155-
print(output_str)
156148
else:
157149
if(out_dir == None or out_dir == ""):
158150
if(docker == 'true'):
159151
try:
160152
output_bytes = subprocess.check_output(["./makedocker", makestudy_dir], cwd=concore_path)
161153
output_str = output_bytes.decode("utf-8")
162154
proc = 0
163-
print(output_str)
164155
except subprocess.CalledProcessError as e:
165156
output_str = f"Docker study creation failed with return code {e.returncode} (check duplicate directory)"
166157
proc = 1
167-
print(output_str)
168158
else:
169159
try:
170160
output_bytes = subprocess.check_output(["./makestudy", makestudy_dir], cwd=concore_path)
171161
output_str = output_bytes.decode("utf-8")
172162
proc = 0
173-
print(output_str)
174163
except subprocess.CalledProcessError as e:
175164
output_str = f"Study creation failed with return code {e.returncode} (check duplicate directory)"
176165
proc = 1
177-
print(output_str)
178166
else:
179167
if(docker == 'true'):
180168
try:
181169
output_bytes = subprocess.check_output(["./makedocker", makestudy_dir, out_dir], cwd=concore_path)
182170
output_str = output_bytes.decode("utf-8")
183171
proc = 0
184-
print(output_str)
185172
except subprocess.CalledProcessError as e:
186173
output_str = f"Docker study creation failed with return code {e.returncode} (check duplicate directory)"
187174
proc = 1
188-
print(output_str)
189175
else:
190176
try:
191177
output_bytes = subprocess.check_output(["./makestudy", makestudy_dir, out_dir], cwd=concore_path)
192178
output_str = output_bytes.decode("utf-8")
193179
proc = 0
194-
print(output_str)
195180
except subprocess.CalledProcessError as e:
196181
output_str = f"Study creation failed with return code {e.returncode} (check duplicate directory)"
197182
proc = 1
198-
print(output_str)
199183
if(proc == 0):
200184
resp = jsonify({'message': 'Directory successfully created'})
201185
resp.status_code = 201
@@ -206,11 +190,9 @@ def build(dir):
206190
try:
207191
output_bytes = subprocess.check_output("build", cwd=dir_path, shell=True)
208192
output_str = output_str + output_bytes.decode("utf-8")
209-
print(output_str)
210193
resp = jsonify({'message': 'Directory successfully created', 'output': output_str})
211194
except subprocess.CalledProcessError as e:
212195
output_str = f"Build failed with return code {e.returncode}"
213-
print(output_str)
214196
resp = jsonify({'message': 'Build Failed', 'output': output_str})
215197
resp.status_code = 500
216198
if(maxtime != None and maxtime != ''):
@@ -221,11 +203,9 @@ def build(dir):
221203
try:
222204
output_bytes = subprocess.check_output("./build", cwd=dir_path)
223205
output_str = output_str + output_bytes.decode("utf-8")
224-
print(output_str)
225206
resp = jsonify({'message': 'Directory successfully created', 'output': output_str})
226207
except subprocess.CalledProcessError as e:
227208
output_str = f"Build failed with return code {e.returncode}"
228-
print(output_str)
229209
resp = jsonify({'message': 'Build Failed', 'output': output_str})
230210
resp.status_code = 500
231211
if(maxtime != None and maxtime != ''):
@@ -347,6 +327,30 @@ def destroy(dir):
347327
resp = jsonify({'message': 'There is an Error'})
348328
resp.status_code = 500
349329
return resp
330+
331+
@app.route('/library/<dir>', methods=['POST'])
332+
def library(dir):
333+
dir_name = secure_filename(dir)
334+
dir_path = os.path.abspath(os.path.join(concore_path, dir_name))
335+
filename = request.args.get('filename')
336+
library_path = request.args.get('path')
337+
proc = 0
338+
if (library_path == None or library_path == ''):
339+
library_path = "../tools"
340+
if(platform.uname()[0]=='Windows'):
341+
proc = subprocess.check_output(["..\library", library_path, filename],shell=True, cwd=dir_path)
342+
else:
343+
proc = subprocess.check_output(["../library", library_path, filename], cwd=dir_path)
344+
if(proc != 0):
345+
resp = jsonify({'message': proc.decode("utf-8")})
346+
resp.status_code = 201
347+
return resp
348+
else:
349+
resp = jsonify({'message': 'There is an Error'})
350+
resp.status_code = 500
351+
return resp
352+
353+
350354

351355
@app.route('/getFilesList/<dir>', methods=['POST'])
352356
def getFilesList(dir):

library

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ if [ $# = 0 ]
2525
if [ -e $tooldir/$filename ]
2626
then
2727
ln -s $tooldir/$filename $filename
28+
echo "library link created"
2829
else
29-
echo "$filename does not exist"
30+
echo "$filename does not exist in $tooldir"
3031
fi
3132
else
3233
echo "$tooldir does not exist"

0 commit comments

Comments
 (0)