diff --git a/kadmos/vistoms/templates/VISTOMS.html b/kadmos/vistoms/templates/VISTOMS.html index 88d6dc2f3a000b7d13b6692f732d8a840adb5669..4b3169911adbdf5751f6f384cf0092a46865b665 100644 --- a/kadmos/vistoms/templates/VISTOMS.html +++ b/kadmos/vistoms/templates/VISTOMS.html @@ -259,6 +259,23 @@ }) } //############################################################## + + + //aigner: Function to download data to a file + //############################################################## + function download_from_kadmos(filename, href) { + var element = document.createElement('a'); + element.setAttribute('href', href); + element.setAttribute('download', filename); + + element.style.display = 'none'; + document.body.appendChild(element); + + element.click(); + + document.body.removeChild(element); + } + //############################################################## function makeKadmosMenu(data, initial=false) @@ -899,47 +916,67 @@ $('#saveForm').on('submit',function(event){ event.preventDefault(); //aigner: Uploading files for KADMOS - bootbox.prompt( + //########################################################## + bootbox.hideAll(); + var bootboxContent = {title: "Save changes to file", message: '<p>Please be patient...</p>'}; + var xhr = $.ajax( { - title: "<p>The graphs will be downloaded to your computer</p>" - +"<p>Please type in the path of the directory</p>", - value: "", - placeholder: "path...", - callback: function(path) - { - if (path) + type: 'POST', + data: {'fileType': selectValue}, + url: '/kadmos_export_all_graphs', + success: function(result) + { + var files = result + files.forEach(function(file) { - //########################################################## - var bootboxContent = {title: "Save all graphs", message: '<p>Please be patient...</p>'}; - var xhr = $.ajax({ - type: 'POST', - data: {'path': path, 'fileType': selectValue}, - url: '/kadmos_export_all_graphs', - success: function(result) - { - if (result.includes("ERROR:")) - { - bootboxContent.message = result - kadmosErrorMessage(bootboxContent); - } - else - { - bootboxContent.message = "Successfully downloaded the file(s) to <b>"+result+"</b>" - kadmosSuccessMessage(bootboxContent); - } - }, - error: function(result) + download_from_kadmos(file,"/kadmos_download/"+file) + }) + + + if (result.includes("ERROR:")) + { + bootboxContent.message = result + kadmosErrorMessage(bootboxContent); + } + else + { + bootboxContent.message = "Successfully created the files. Ready for download." + bootbox.hideAll(); + bootbox.dialog( + { + title: bootboxContent.title, + message: bootboxContent.message, + buttons : {cancel: { - bootboxContent.message = result - kadmosErrorMessage(bootboxContent); - } - }); - kadmosHavePatience(xhr, bootboxContent) - //########################################################## + label: "OK", + callback: function(){remove_obsolete_files()} + }} + }); } - + }, + error: function(result) + { + bootboxContent.message = result + kadmosErrorMessage(bootboxContent); } - }) + }); + kadmosHavePatience(xhr, bootboxContent) + + //Remove obsolete files + function remove_obsolete_files() + { + $.ajax({ + type: 'POST', + url: '/kadmos_remove_obsolete_files', + success: function(result){}, + error: function(result) + { + bootboxContent.message = result + kadmosErrorMessage(bootboxContent); + } + }); + } + //########################################################## }); } d3.select("#mainPage").moveToFront() @@ -19968,7 +20005,7 @@ //#################################################################################################################### //aigner: KADMOS function Save graph //#################################################################################################################### - //aigner: Function to download data to a file + // Function to download data to a file function download(filename, text) { var element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); @@ -19981,46 +20018,54 @@ document.body.removeChild(element); } - + + //aigner: Export changes --> Download as CMDOWS file function exportChangesToFile(fileType) { bootbox.hideAll(); var bootboxContent = {title: "Save changes to file", message: '<p>Please be patient...</p>'}; - bootbox.prompt( + var xhr = $.ajax( { - title: "<p>The graph will be downloaded to your computer</p>" - +"<p>Please type in the path of the directory</p>", - value: "", - placeholder: "path...", - callback: function(path) + type: 'POST', + data: {'fileName':currentGraph.name, 'fileType': fileType, 'graphID': graphID}, + url: '/kadmos_export_graph', + success: function(result) + { + var element = document.createElement('a'); + download_from_kadmos(result, "/kadmos_download/"+result) + }, + error: function(result) { - var xhr = $.ajax({ - type: 'POST', - data: {'path':path, 'fileName':currentGraph.name, 'fileType': fileType, 'graphID': graphID, 'currentOrder': nodeOrder}, - url: '/kadmos_export_graph', - success: function(result) - { - if (result.includes("ERROR:")) - { - bootboxContent.message = result - kadmosErrorMessage(bootboxContent); - } - else - { - bootboxContent.message = "Successfully downloaded the file(s) to <b>"+result+"</b>" - kadmosSuccessMessage(bootboxContent); - } - }, - error: function(result) - { - bootboxContent.message = result - kadmosErrorMessage(bootboxContent); - } - }); - kadmosHavePatience(xhr, bootboxContent) + bootboxContent.message = result + kadmosErrorMessage(bootboxContent); } - }) + }); + kadmosHavePatience(xhr, bootboxContent) + + //Remove obsolete files + $.ajax({ + type: 'POST', + url: '/kadmos_remove_obsolete_files', + success: function(result) + { + if (result.includes("ERROR:")) + { + bootboxContent.message = result + kadmosErrorMessage(bootboxContent); + } + else + { + bootboxContent.message = "Successfully created the file. Ready for download." + kadmosSuccessMessage(bootboxContent); + } + }, + error: function(result) + { + bootboxContent.message = result + kadmosErrorMessage(bootboxContent); + } + }); } @@ -21028,7 +21073,7 @@ bootbox.hideAll(); bootbox.prompt({ title: "<b>Contact information</b>" - +"<p>Which contact do you want to show or edit?" + +"<p>Which contact do you want to show or edit?<br>" +"You can also add a new contact. Just select 'Add new contact'</p>", inputType: 'select', value: 'select', @@ -22527,7 +22572,7 @@ +" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n" +" return graph, mpg\n" - download('script_template.py',script_template); + download('script_template.py', script_template); }) //upload of custom script $('#scriptForm').on('submit',function(event){ @@ -23655,7 +23700,7 @@ var xmlString = serializer.serializeToString(xmlDocument); xmlString = vkbeautify.xml(xmlString); //Download a document with the xml-schema - download(aName+'_full.xml',xmlString); + download(aName+'_full.xml', xmlString); }, onMouseUp: function(elm, d, i) { }, @@ -23680,7 +23725,7 @@ xmlString = serializer.serializeToString(xmlDocument); xmlString = vkbeautify.xml(xmlString); //Download a document with the xml-schema - download(aName+"_"+d.data.name+'.xml',xmlString); + download(aName+"_"+d.data.name+'.xml', xmlString); }, onMouseUp: function(elm, d, i) { }, @@ -24099,169 +24144,6 @@ } }); } - - //Function writeTreeToXML goes through tree nodes and puts the into an xml document - function writeTreeToXML(aNode,anXMLDoc,anXPath) - { - //Variable "children" - //--> One children variable, no matter whether a node has "_children" (collapsed) or "children" (expanded) - var children; - if (aNode._children){children = aNode._children;} - else if (aNode.children){children = aNode.children;} - - //Get current xml element with its xPath - var element = anXMLDoc.evaluate(anXPath,anXMLDoc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; - if (element != null) {element.value = '...';} - - //If a node has children (collapsed or expanded), loop through them - if (children) - { - for (var i=0; i < children.length;i++) - { - //Name of the new XML element --> childName - var child = children[i]; - var childName = child.name.split(/[\[\]]+/);//Split childName at "[]" which is the uID - var cleanChildName = childName[0].split(/[\+\*\^\-\ \#]+/);//Split childName all special characters - var newNode = anXMLDoc.createElement(String(cleanChildName[0])); - - //The children are appended to the xPath --> newXPath - var newXPath = anXPath+"/"+cleanChildName[0]; - - //If childName contains a uID, make the uID an attribute - if (childName[1]) - { - if (parseInt(childName[1])) - { - var dummyID = childName[1]; - newNode.setAttribute("dummyID", dummyID) - newXPath = newXPath+"[@dummyID='"+dummyID+"']"; - } - else - { - var uID = childName[1]; - newNode.setAttribute("uID", uID) - newXPath = newXPath+"[@uID='"+uID+"']"; - } - } - if (cleanChildName.length>1) {newNode.setAttribute("elementName", childName[0])}; - - //Append the newNode to the xml structure - element.appendChild(newNode); - - - - ////aigner: Sorting of XML elements according to "uID" - // var items = element.children; - // var itemsArr = []; - // for (var j in items) { - // if (items[j].nodeType == 1) { // get rid of the whitespace text nodes - // itemsArr.push(items[j]); - // } - // } - // itemsArr.sort(function(a,b){ - // if (a.getAttribute("uID") < b.getAttribute("uID")) - // return -1; - // if (a.getAttribute("uID") > b.getAttribute("uID")) - // return 1; - // return 0; - // }); - - // for (j = 0; j < itemsArr.length; ++j) { - // element.appendChild(itemsArr[j]); - // } - - //call function writeTreeToXML recursively for all children - writeTreeToXML(child,anXMLDoc,newXPath) - } - } - else - { - if (aNode.value){element.innerHTML = String(aNode.value);} - else{element.innerHTML = " ";} - } - //return the xml document - return anXMLDoc; - } - - function removeAttributeInAllElements(aDocument,attribute) - { - var matchingElements = []; - var allElements = aDocument.getElementsByTagName('*'); - for (var i = 0, n = allElements.length; i < n; i++) - { - if (allElements[i].getAttribute(attribute) !== null) - { - allElements[i].removeAttribute(attribute); - } - } - return matchingElements; - } - - function putAncestorsInXMLString(strWrapper, aNode) - { - //Name of the new XML element - var nodeName = aNode.name.split(/[\[\]]+/);//Split name at "[]" which is the uID - var cleanNodeName = nodeName[0].split(/[\+\*\^\-\ \#]+/);//Split nodeName all special characters - //If nodeName contains a uID, make the uID an attribute - if (nodeName[1]) - { - var uID = nodeName[1]; - strWrapper.val = "<"+cleanNodeName[0]+" uID='"+ uID +"'>"+strWrapper.val+"</"+cleanNodeName[0]+">";; - } - else - { - strWrapper.val = "<"+cleanNodeName[0]+">"+strWrapper.val+"</"+cleanNodeName[0]+">";; - } - var aParent = aNode.parent; - if (aParent) - { - return putAncestorsInXMLString(strWrapper, aParent); - } - else - { - return strWrapper; - } - } - - function putAncestorsInXPath(strWrapper, aNode) - { - //Name of the new XML element - var nodeName = aNode.name.split(/[\[\]]+/);//Split name at "[]" which is the uID - var cleanNodeName = nodeName[0].split(/[\+\*\^\-\ \#]+/);//Split nodeName all special characters - //If nodeName contains a uID, make the uID an attribute - if (nodeName[1]) - { - var uID = nodeName[1]; - strWrapper.val = "/"+cleanNodeName[0]+"[@uID='"+uID+"']"+strWrapper.val; - } - else - { - strWrapper.val = "/"+cleanNodeName[0]+strWrapper.val; - } - var aParent = aNode.parent; - if (aParent) - { - return putAncestorsInXPath(strWrapper, aParent); - } - else - { - return strWrapper; - } - } - - // Function to download data to a file - function download(filename, text) { - var element = document.createElement('a'); - element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); - element.setAttribute('download', filename); - - element.style.display = 'none'; - document.body.appendChild(element); - - element.click(); - - document.body.removeChild(element); - } function showVariableTable(aVariable) { @@ -25777,6 +25659,170 @@ else{return "#fff";} }) + //Function writeTreeToXML goes through tree nodes and puts the into an xml document + function writeTreeToXML(aNode,anXMLDoc,anXPath) + { + //Variable "children" + //--> One children variable, no matter whether a node has "_children" (collapsed) or "children" (expanded) + var children; + if (aNode._children){children = aNode._children;} + else if (aNode.children){children = aNode.children;} + + //Get current xml element with its xPath + var element = anXMLDoc.evaluate(anXPath,anXMLDoc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; + if (element != null) {element.value = '...';} + + //If a node has children (collapsed or expanded), loop through them + if (children) + { + for (var i=0; i < children.length;i++) + { + //Name of the new XML element --> childName + var child = children[i]; + var childName = child.name.split(/[\[\]]+/);//Split childName at "[]" which is the uID + var cleanChildName = childName[0].split(/[\+\*\^\-\ \#]+/);//Split childName all special characters + var newNode = anXMLDoc.createElement(String(cleanChildName[0])); + + //The children are appended to the xPath --> newXPath + var newXPath = anXPath+"/"+cleanChildName[0]; + + //If childName contains a uID, make the uID an attribute + if (childName[1]) + { + if (parseInt(childName[1])) + { + var dummyID = childName[1]; + newNode.setAttribute("dummyID", dummyID) + newXPath = newXPath+"[@dummyID='"+dummyID+"']"; + } + else + { + var uID = childName[1]; + newNode.setAttribute("uID", uID) + newXPath = newXPath+"[@uID='"+uID+"']"; + } + } + if (cleanChildName.length>1) {newNode.setAttribute("elementName", childName[0])}; + + //Append the newNode to the xml structure + element.appendChild(newNode); + + + + ////aigner: Sorting of XML elements according to "uID" + // var items = element.children; + // var itemsArr = []; + // for (var j in items) { + // if (items[j].nodeType == 1) { // get rid of the whitespace text nodes + // itemsArr.push(items[j]); + // } + // } + // itemsArr.sort(function(a,b){ + // if (a.getAttribute("uID") < b.getAttribute("uID")) + // return -1; + // if (a.getAttribute("uID") > b.getAttribute("uID")) + // return 1; + // return 0; + // }); + + // for (j = 0; j < itemsArr.length; ++j) { + // element.appendChild(itemsArr[j]); + // } + + //call function writeTreeToXML recursively for all children + writeTreeToXML(child,anXMLDoc,newXPath) + } + } + else + { + if (aNode.value){element.innerHTML = String(aNode.value);} + else{element.innerHTML = " ";} + } + //return the xml document + return anXMLDoc; + } + + function removeAttributeInAllElements(aDocument,attribute) + { + var matchingElements = []; + var allElements = aDocument.getElementsByTagName('*'); + for (var i = 0, n = allElements.length; i < n; i++) + { + if (allElements[i].getAttribute(attribute) !== null) + { + allElements[i].removeAttribute(attribute); + } + } + return matchingElements; + } + + function putAncestorsInXMLString(strWrapper, aNode) + { + //Name of the new XML element + var nodeName = aNode.name.split(/[\[\]]+/);//Split name at "[]" which is the uID + var cleanNodeName = nodeName[0].split(/[\+\*\^\-\ \#]+/);//Split nodeName all special characters + //If nodeName contains a uID, make the uID an attribute + if (nodeName[1]) + { + var uID = nodeName[1]; + strWrapper.val = "<"+cleanNodeName[0]+" uID='"+ uID +"'>"+strWrapper.val+"</"+cleanNodeName[0]+">";; + } + else + { + strWrapper.val = "<"+cleanNodeName[0]+">"+strWrapper.val+"</"+cleanNodeName[0]+">";; + } + var aParent = aNode.parent; + if (aParent) + { + return putAncestorsInXMLString(strWrapper, aParent); + } + else + { + return strWrapper; + } + } + + function putAncestorsInXPath(strWrapper, aNode) + { + //Name of the new XML element + var nodeName = aNode.name.split(/[\[\]]+/);//Split name at "[]" which is the uID + var cleanNodeName = nodeName[0].split(/[\+\*\^\-\ \#]+/);//Split nodeName all special characters + //If nodeName contains a uID, make the uID an attribute + if (nodeName[1]) + { + var uID = nodeName[1]; + strWrapper.val = "/"+cleanNodeName[0]+"[@uID='"+uID+"']"+strWrapper.val; + } + else + { + strWrapper.val = "/"+cleanNodeName[0]+strWrapper.val; + } + var aParent = aNode.parent; + if (aParent) + { + return putAncestorsInXPath(strWrapper, aParent); + } + else + { + return strWrapper; + } + } + + // Function to download data to a file + function download(filename, text) { + var element = document.createElement('a'); + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); + element.setAttribute('download', filename); + + element.style.display = 'none'; + document.body.appendChild(element); + + element.click(); + + document.body.removeChild(element); + } + + var nodeTreeMenu = nodeMenu; var treeMenu = [ { @@ -25797,7 +25843,7 @@ var xmlString = serializer.serializeToString(xmlDocument); xmlString = vkbeautify.xml(xmlString); //Download a document with the xml-schema - download(theName+'_full.xml',xmlString); + download(theName+'_full.xml', xmlString); }, onMouseUp: function(elm, d, i) { }, @@ -25822,7 +25868,7 @@ xmlString = serializer.serializeToString(xmlDocument); xmlString = vkbeautify.xml(xmlString); //Download a document with the xml-schema - download(theName+"_"+d.name+'.xml',xmlString); + download(theName+"_"+d.name+'.xml', xmlString); }, onMouseUp: function(elm, d, i) { }, @@ -28338,17 +28384,17 @@ // Function to download data to a file function download(filename, text) { - var element = document.createElement('a'); - element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); - element.setAttribute('download', filename); + var element = document.createElement('a'); + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); + element.setAttribute('download', filename); - element.style.display = 'none'; - document.body.appendChild(element); + element.style.display = 'none'; + document.body.appendChild(element); - element.click(); + element.click(); - document.body.removeChild(element); - } + document.body.removeChild(element); + } var treeNodeMenu = nodeMenu; @@ -28371,7 +28417,7 @@ var xmlString = serializer.serializeToString(xmlDocument); xmlString = vkbeautify.xml(xmlString); //Download a document with the xml-schema - download(theName+'_full.xml',xmlString); + download(theName+'_full.xml', xmlString); }, onMouseUp: function(elm, d, i) { }, @@ -28396,7 +28442,7 @@ xmlString = serializer.serializeToString(xmlDocument); xmlString = vkbeautify.xml(xmlString); //Download a document with the xml-schema - download(theName+"_"+d.name+'.xml',xmlString); + download(theName+"_"+d.name+'.xml', xmlString); }, onMouseUp: function(elm, d, i) { }, diff --git a/kadmos/vistoms/vistoms.py b/kadmos/vistoms/vistoms.py index 774865bb297872fe43f46a1367a984d68406cdd9..8c801d24d7a4a90577c89b670dd29bab6ddbcbeb 100644 --- a/kadmos/vistoms/vistoms.py +++ b/kadmos/vistoms/vistoms.py @@ -8,17 +8,16 @@ import shutil import sys import tempfile import webbrowser +import xml.etree.ElementTree as ET import zipfile from copy import deepcopy from shutil import copyfile -import xml.etree.ElementTree as ET import networkx as nx -from flask import Flask, render_template, request, jsonify +from flask import Flask, render_template, request, jsonify, send_from_directory from kadmos.cmdows.cmdows import find_cmdows_file from kadmos.graph import load, FundamentalProblemGraph, KadmosGraph - app = Flask(__name__) # Folder and file settings @@ -196,12 +195,9 @@ def kadmos_export_all_graphs(): """ try: # Get request form - path = os.path.join(request.form['path'],'') fileType = request.form['fileType'] - if not os.path.isdir(path): - os.makedirs(os.path.dirname(path)) - + files = [] for aFile in os.listdir(UPLOAD_FOLDER): if aFile.endswith(".kdms"): fileName = aFile.split('.')[0] @@ -238,25 +234,51 @@ def kadmos_export_all_graphs(): file_type = "cmdows" file = graph_name + ".xml" # Save as CMDOWS file - graph.save(os.path.join(UPLOAD_FOLDER, graph_name), file_type=file_type, graph_check_critical=False, mpg=mpg) - # Copy CMDOWS file from temporary folder to user's download folder - copyfile(os.path.join(UPLOAD_FOLDER, file), os.path.join(path, file)) - # remove temporary CMDOWS file - os.remove(os.path.join(UPLOAD_FOLDER, file)) + file_copy = file + count = 0 + while os.path.exists(os.path.join(UPLOAD_FOLDER, file_copy)): + count += 1 + file_copy = graph_name + "(" + str(count) + ")" + ".xml" + graph.save(os.path.join(UPLOAD_FOLDER, file_copy), file_type=file_type, + graph_check_critical=False, mpg=mpg) + files.append(file_copy) + elif fileType == "KDMS files": file_type = "kdms" - # Save as kdms file - graph.save(os.path.join(UPLOAD_FOLDER, graph_name), file_type=file_type, graph_check_critical=False, mpg=mpg) file = graph_name + ".kdms" - mpgfile = graph_name + "_mpg.kdms" - # Copy kdms file from temporary folder to user's download folder - copyfile(os.path.join(UPLOAD_FOLDER, file), os.path.join(path, file)) - # remove temporary kdms file - os.remove(os.path.join(UPLOAD_FOLDER, file)) - if os.path.exists(os.path.join(UPLOAD_FOLDER, mpgfile)): - copyfile(os.path.join(UPLOAD_FOLDER, mpgfile), os.path.join(path, mpgfile)) - os.remove(os.path.join(UPLOAD_FOLDER, mpgfile)) - return path + # Save as kdms file + file_copy = file + count = 0 + while os.path.exists(os.path.join(UPLOAD_FOLDER, file_copy)): + count += 1 + file_copy = graph_name + "(" + str(count) + ")" + ".kdms" + graph.save(os.path.join(UPLOAD_FOLDER, file_copy), file_type=file_type, + graph_check_critical=False, mpg=mpg) + files.append(file_copy) + return jsonify(files) + + except Exception as e: + return "ERROR: " + e.message + # Logs the error appropriately. + + +@app.route('/kadmos_download/<path:filename>') +def kadmos_download(filename): + try: + return send_from_directory(directory=UPLOAD_FOLDER, filename=filename) + + except Exception as e: + return "ERROR: " + e.message + # Logs the error appropriately. + + +@app.route('/kadmos_remove_obsolete_files', methods=['POST']) +def kadmos_remove_obsolete_files(): + try: + for file in os.listdir(UPLOAD_FOLDER): + if "tmp_" not in file: + os.remove(os.path.join(UPLOAD_FOLDER, file)) + return "" except Exception as e: return "ERROR: " + e.message @@ -273,11 +295,9 @@ def kadmos_export_graph(): """ try: # Get request form - path = os.path.join(request.form['path'], '') fileName = request.form['fileName'] graphID = request.form['graphID'] fileType = request.form['fileType'] - functionOrder = request.form['currentOrder'].split(',') graphFileName = TEMP_FILE+'_'+graphID+'.kdms' mpgFileName = TEMP_FILE+'_'+graphID+'_mpg.kdms' @@ -298,25 +318,20 @@ def kadmos_export_graph(): graph.assert_or_add_nested_attribute(['problem_formulation', 'allow_unconverged_couplings'], False) graph.add_function_problem_roles() - if not os.path.isdir(path): - os.makedirs(os.path.dirname(path)) - + # Save as kdms file if fileType == "kdms": - copyfile(os.path.join(UPLOAD_FOLDER, graphFileName), os.path.join(path, fileName+".kdms")) - if os.path.exists(os.path.join(UPLOAD_FOLDER, mpgFileName)): - copyfile(os.path.join(UPLOAD_FOLDER, mpgFileName), os.path.join(path, fileName+'_mpg'+".kdms")) + graph.save(os.path.join(UPLOAD_FOLDER, fileName), file_type=fileType, graph_check_critical=False, mpg=mpg) + file = fileName + ".kdms" + return file + + # Save as CMDOWS file elif fileType == "cmdows": - file = fileName + ".xml" - # Save as CMDOWS file - graph.save(os.path.join(UPLOAD_FOLDER, fileName), file_type=fileType,graph_check_critical=False, mpg=mpg) - # Copy CMDOWS file from temporary folder to user's download folder - copyfile(os.path.join(UPLOAD_FOLDER, file), os.path.join(path, file)) - # remove temporary CMDOWS file - os.remove(os.path.join(UPLOAD_FOLDER, file)) - else: - return ("ERROR: Wrong file type!!!") + graph.save(os.path.join(UPLOAD_FOLDER, fileName), file_type=fileType, graph_check_critical=False, mpg=mpg) + file = fileName+".xml" + return file - return (path) + else: + return "ERROR: Wrong file type!!!" except Exception as e: return "ERROR: " + e.message