Skip to content
Snippets Groups Projects
Commit 49c1a268 authored by imcovangent's avatar imcovangent
Browse files

Small bug fix for VISTOMS interface.

Former-commit-id: d460b22e25efe8e609fb5f65c60a99948436e6fc
parent 5c78c50d
No related branches found
No related tags found
No related merge requests found
......@@ -193,43 +193,41 @@ def interface(debug=True, tempdir=None):
loaded_graph = load(graphFileName, file_check_critical=False)
if "name" not in loaded_graph.graph:
loaded_graph.graph["name"] = os.path.splitext(dgFile.filename)[0].replace("_",".")
# Remove the uploaded file (and if existing, database directory) from the temp folder
os.remove(graphFileName)
if os.path.exists(database_dir):
shutil.rmtree(database_dir)
if isinstance(loaded_graph, tuple):
graph = loaded_graph[0]
mpg = loaded_graph[1]
elif mpgFile:
# Check if the right filetype was chosen
if mpgFile.filename.rsplit('.', 1)[1].lower() != "kdms":
return ("ERROR: Wrong file type! Please use a valid KDMS file")
graph = loaded_graph
mpgFileName = mpgFile.filename
mpgFile.save(os.path.join(upload_folder, mpgFileName))
mpg = load(os.path.join(upload_folder, mpgFileName), file_check_critical=True)
# Remove the uploaded file from the temp folder
os.remove(os.path.join(upload_folder, mpgFileName))
else:
graph = loaded_graph
mpg = None
# save the graph as kdms file in temp folder
graph.save(os.path.join(upload_folder, TEMP_FILE + '_' + newGraphID + '.kdms'), file_type='kdms',
graph_check_critical=False, mpg=mpg)
# Remove the uploaded file (and if existing, database directory) from the temp folder
os.remove(graphFileName)
if os.path.exists(database_dir):
shutil.rmtree(database_dir)
if isinstance(loaded_graph, tuple):
graph = loaded_graph[0]
mpg = loaded_graph[1]
elif mpgFile:
# Check if the right filetype was chosen
if mpgFile.filename.rsplit('.', 1)[1].lower() != "kdms":
return ("ERROR: Wrong file type! Please use a valid KDMS file")
graph = loaded_graph
mpgFileName = mpgFile.filename
mpgFile.save(os.path.join(upload_folder, mpgFileName))
mpg = load(os.path.join(upload_folder, mpgFileName), file_check_critical=True)
# Remove the uploaded file from the temp folder
os.remove(os.path.join(upload_folder, mpgFileName))
else:
graph = loaded_graph
mpg = None
# Use function order for VISTOMS if it is available in the graph information
function_order = None
if graph.graph_has_nested_attributes('problem_formulation', 'function_order') and mpg == None:
function_order = graph.graph['problem_formulation']['function_order']
# save the graph as kdms file in temp folder
graph.save(os.path.join(upload_folder, TEMP_FILE + '_' + newGraphID + '.kdms'), file_type='kdms',
graph_check_critical=False, mpg=mpg)
# Add the graph with the updated function order to VISTOMS
newVistomsData = graph.vistoms_add_json(graph_id=newGraphID, function_order=function_order, mpg=mpg)
# Use function order for VISTOMS if it is available in the graph information
function_order = None
if graph.graph_has_nested_attributes('problem_formulation', 'function_order') and mpg == None:
function_order = graph.graph['problem_formulation']['function_order']
return newVistomsData
# Add the graph with the updated function order to VISTOMS
newVistomsData = graph.vistoms_add_json(graph_id=newGraphID, function_order=function_order, mpg=mpg)
return ("ERROR: File type " + dgFile.filename.rsplit('.', 1)[1].lower() + " not allowed!")
return newVistomsData
except Exception as e:
return "ERROR: " + e.message
......@@ -514,7 +512,7 @@ def interface(debug=True, tempdir=None):
upload_folder = UPLOAD_FOLDERS[sessionID]
# First of all, delete all graphs, that end with a _backup
delete_backup_graphs()
delete_backup_graphs(upload_folder)
tmpDir = upload_folder
newVIstomsDataArray = []
......
......@@ -434,7 +434,7 @@
var xhr = $.ajax({
type: 'POST',
url: '/kadmos_add_design_competence',
data: {'graphID':graphID, 'currentOrder':nodeOrder, 'form_data':JSON.stringify(form_data), 'sessionID:sessionID},
data: {'graphID':graphID, 'currentOrder':nodeOrder, 'form_data':JSON.stringify(form_data), 'sessionID':sessionID},
success: function(result)
{
if (result.includes("ERROR:"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment