Skip to content
Merged
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
25 changes: 25 additions & 0 deletions fri/server/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Flask, request, jsonify, send_file, send_from_directory
from werkzeug.utils import secure_filename
import xml.etree.ElementTree as ET
import os
import subprocess
from subprocess import call
Expand All @@ -18,6 +19,17 @@
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'

def check_node_labels(graphml_file):
tree = ET.parse(graphml_file)
root = tree.getroot()
namespace = {'y': 'http://www.yworks.com/xml/graphml'}
node_labels = root.findall('.//y:NodeLabel', namespace)
for node_label in node_labels:
label = node_label.text
if label.endswith('.m'):
return True
return False

# To upload multiple file. For example, /upload/test?apikey=xyz
@app.route('/upload/<dir>', methods=['POST'])
def upload(dir):
Expand Down Expand Up @@ -68,6 +80,7 @@ def build(dir):
graphml_file = request.args.get('fetch')
params = request.args.get('params')
docker = request.args.get('docker')
octave = request.args.get('octave')
maxtime = request.args.get('maxtime')
apikey = request.args.get('apikey')
out_dir = request.args.get('outdir')
Expand All @@ -80,6 +93,14 @@ def build(dir):
dir_path = os.path.abspath(os.path.join(concore_path, graphml_file)) #path for ./build
else:
dir_path = os.path.abspath(os.path.join(concore_path, out_dir)) #path for ./build

dotMCheck = check_node_labels(os.path.abspath(os.path.join(concore_path, makestudy_dir)) + '.graphml')
if((dotMCheck == False or octave == 'false') and os.path.isfile(os.path.abspath(os.path.join(concore_path, 'concore.octave')))):
if(platform.uname()[0]!='Windows'):
proc= call(["rm", "concore.octave"], cwd=concore_path)
else:
proc= call(["del", "concore.octave"], cwd=concore_path)

if not os.path.exists(dir_path):
if(platform.uname()[0]=='Windows'):
if(out_dir == None or out_dir == ""):
Expand All @@ -95,11 +116,15 @@ def build(dir):
else:
if(out_dir == None or out_dir == ""):
if(docker == 'true'):
if(octave == 'true' and dotMCheck):
proc= call(["touch", "concore.octave"], cwd=concore_path)
proc= call(["./makedocker", makestudy_dir], cwd=concore_path)
else:
proc= call(["./makestudy", makestudy_dir], cwd=concore_path)
else:
if(docker == 'true'):
if(octave == 'true' and dotMCheck):
proc= call(["touch", "concore.octave"], cwd=concore_path)
proc= call(["./makedocker", makestudy_dir, out_dir], cwd=concore_path)
else:
proc= call(["./makestudy", makestudy_dir, out_dir], cwd=concore_path)
Expand Down