From 213fb5286c4bcda3ce38a964b8160c8fb7d0ec98 Mon Sep 17 00:00:00 2001 From: Rahul Date: Sun, 25 Jun 2023 23:41:12 +0530 Subject: [PATCH 1/2] octave made active --- fri/server/main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/fri/server/main.py b/fri/server/main.py index 105a490..c12d3aa 100644 --- a/fri/server/main.py +++ b/fri/server/main.py @@ -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 @@ -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/', methods=['POST']) def upload(dir): @@ -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') @@ -80,6 +93,11 @@ 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')))): + proc= call(["rm", "concore.octave"], cwd=concore_path) + if not os.path.exists(dir_path): if(platform.uname()[0]=='Windows'): if(out_dir == None or out_dir == ""): @@ -95,11 +113,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) From 6b5812a5a06b4cb7f1884caee15ca6d5a3fa5ff0 Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 29 Jun 2023 18:07:45 +0530 Subject: [PATCH 2/2] deletion of octave in windows --- fri/server/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fri/server/main.py b/fri/server/main.py index c12d3aa..363bc35 100644 --- a/fri/server/main.py +++ b/fri/server/main.py @@ -96,7 +96,10 @@ def build(dir): 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')))): - proc= call(["rm", "concore.octave"], cwd=concore_path) + 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'):