diff --git a/kadmos/vistoms/vistoms.py b/kadmos/vistoms/vistoms.py index 8c801d24d7a4a90577c89b670dd29bab6ddbcbeb..db1f10f88c026cb4f760e59776473930279ac399 100644 --- a/kadmos/vistoms/vistoms.py +++ b/kadmos/vistoms/vistoms.py @@ -16,7 +16,7 @@ from shutil import copyfile import networkx as nx 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 +from kadmos.graph import load, FundamentalProblemGraph, KadmosGraph, RepositoryConnectivityGraph app = Flask(__name__) @@ -106,13 +106,6 @@ def kadmos_upload_file(): dgFile.save(os.path.join(UPLOAD_FOLDER, dgFile.filename)) 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] @@ -130,6 +123,13 @@ def kadmos_upload_file(): graph = loaded_graph mpg = None + if "name" not in graph.graph: + 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) + #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) @@ -990,6 +990,13 @@ def kadmos_add_design_competence(): # Here the original graph and the new graph including the design competence are merged new_graph = KadmosGraph(nx.compose(graph, graph_dc)) + if isinstance(graph, RepositoryConnectivityGraph): + new_graph = RepositoryConnectivityGraph(new_graph) + elif isinstance(graph, FundamentalProblemGraph): + new_graph = FundamentalProblemGraph(new_graph) + else: + raise AssertionError("ERROR: Could not do this!") + # new_graph.graph['name'] = graph.graph['name'] # new_graph.graph['id'] = graphID # new_graph.graph['description'] = graph.graph['description'] @@ -1981,7 +1988,7 @@ if __name__ == '__main__': folder = os.path.join(args[args.index('-folder') + 1],'') assert isinstance(folder, basestring), 'Folder should be a string.' else: - folder = None + folder = "C:/Users/aigne/Desktop/vistoms_tmp" # Check if open_vistoms is given in args if '-open' in args: open_vistoms = args[args.index('-open') + 1]