From 74dd0c335c56a6a5d26f103b5969cc8869904170 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Fri, 5 Oct 2012 21:21:29 +0200 Subject: [PATCH] Improving user information messages --- src/daSalome/daGUI/daGuiImpl/adaoCase.py | 13 +- .../daGUI/daGuiImpl/adaoGuiManager.py | 10 +- .../daYacsSchemaCreator/help_methods.py | 143 +++++++----------- src/daSalome/daYacsSchemaCreator/methods.py | 71 +++------ src/daSalome/daYacsSchemaCreator/run.py | 7 +- 5 files changed, 83 insertions(+), 161 deletions(-) diff --git a/src/daSalome/daGUI/daGuiImpl/adaoCase.py b/src/daSalome/daGUI/daGuiImpl/adaoCase.py index 1ad9a27..753f745 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoCase.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoCase.py @@ -64,7 +64,7 @@ class AdaoCase: def createYACSFile(self): rtn = "" if (self.filename == ""): - return "You need to save your case to export it" + return "You need to save your case to export it." self.yacs_filename = self.filename[:self.filename.rfind(".")] + '.xml' yacs_filename_backup = self.filename[:self.filename.rfind(".")] + '.xml.back' @@ -75,12 +75,12 @@ class AdaoCase: self.eficas_editor.saveFile() filename = self.filename[:self.filename.rfind(".")] + '.py' if not os.path.exists(filename): - msg = "Cannot find the py file for YACS generation \n" - msg += "Is your case correct ? \n" + msg = "Cannot find the COMM associated python file for YACS\n" + msg += "generation. Is your case correct?\n" return msg if not os.environ.has_key("ADAO_ROOT_DIR"): - return "Please add ADAO_ROOT_DIR to your environnement" + return "Please add ADAO_ROOT_DIR to your environnement." adao_path = os.environ["ADAO_ROOT_DIR"] adao_exe = adao_path + "/bin/salome/AdaoYacsSchemaCreator.py" @@ -88,8 +88,9 @@ class AdaoCase: p = subprocess.Popen(args) (stdoutdata, stderrdata) = p.communicate() if not os.path.exists(self.yacs_filename): - msg = "An error occured during the execution of AdaoYacsSchemaCreator.py \n" - msg += "See erros details in your terminal \n" + msg = "An error occured during the execution of the ADAO YACS Schema\n" + msg += "Creator. If SALOME is launched by command line, see errors\n" + msg += "details in your terminal.\n" return msg return rtn diff --git a/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py b/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py index 9a49a6b..f573d97 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py @@ -373,19 +373,19 @@ class AdaoGuiUiComponentBuilder: # create toolbar tid = sgPyQt.createTool( "ADAO" ) - a = sgPyQt.createAction( UI_ELT_IDS.NEW_ADAOCASE_ID, "New case", "New case", "Create a new adao case", "eficas_new.png" ) + a = sgPyQt.createAction( UI_ELT_IDS.NEW_ADAOCASE_ID, "New case", "New case", "Create a new ADAO case", "eficas_new.png" ) sgPyQt.createMenu(a, mid) sgPyQt.createTool(a, tid) - a = sgPyQt.createAction( UI_ELT_IDS.OPEN_ADAOCASE_ID, "Open case", "Open case", "Open an adao case", "eficas_open.png" ) + a = sgPyQt.createAction( UI_ELT_IDS.OPEN_ADAOCASE_ID, "Open case", "Open case", "Open an ADAO case", "eficas_open.png" ) sgPyQt.createMenu(a, mid) sgPyQt.createTool(a, tid) - a = sgPyQt.createAction( UI_ELT_IDS.SAVE_ADAOCASE_ID, "Save case", "Save case", "Save an adao case", "eficas_save.png" ) + a = sgPyQt.createAction( UI_ELT_IDS.SAVE_ADAOCASE_ID, "Save case", "Save case", "Save an ADAO case", "eficas_save.png" ) sgPyQt.createMenu(a, mid) sgPyQt.createTool(a, tid) - a = sgPyQt.createAction( UI_ELT_IDS.SAVE_AS_ADAOCASE_ID, "Save as case", "Save as case", "Save an adao case as", "eficas_saveas.png" ) + a = sgPyQt.createAction( UI_ELT_IDS.SAVE_AS_ADAOCASE_ID, "Save as case", "Save as case", "Save an ADAO case as", "eficas_saveas.png" ) sgPyQt.createMenu(a, mid) sgPyQt.createTool(a, tid) - a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close an adao case", "eficas_close.png" ) + a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close an ADAO case", "eficas_close.png" ) sgPyQt.createMenu(a, mid) sgPyQt.createTool(a, tid) a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_ID, "Export to YACS", "Export to YACS", "Generate a YACS graph executing this case", "eficas_yacs.png" ) diff --git a/src/daSalome/daYacsSchemaCreator/help_methods.py b/src/daSalome/daYacsSchemaCreator/help_methods.py index 90e195d..639ce6c 100644 --- a/src/daSalome/daYacsSchemaCreator/help_methods.py +++ b/src/daSalome/daYacsSchemaCreator/help_methods.py @@ -17,7 +17,7 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# Author: André Ribes, andre.ribes@edf.fr, EDF R&D +# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D import sys import os @@ -30,8 +30,7 @@ def check_args(args): logging.debug("Arguments are :" + str(args)) if len(args) != 2: - logging.fatal("Bad number of arguments: you have to provide two arguments (%d given)" % (len(args))) - sys.exit(1) + raise ValueError("\n\n Bad number of arguments: you have to provide two arguments (%d given)\n" % (len(args))) def check_study(study_config): @@ -39,23 +38,19 @@ def check_study(study_config): # Check study_config if not isinstance(study_config, dict): - logging.fatal("Study configuration is not a dictionnary") - sys.exit(1) + raise ValueError("\n\n Study configuration is not a dictionnary!\n") # Name if "Name" not in study_config: - logging.fatal("Cannot found Name in the study configuration") - sys.exit(1) + raise ValueError("\n\n Cannot find Name in the study configuration!\n") # Algorithm if "Algorithm" not in study_config: - logging.fatal("Cannot found Algorithm in the study configuration") - sys.exit(1) + raise ValueError("\n\n Cannot find Algorithm in the study configuration!\n") else: if not (study_config["Algorithm"] in AssimAlgos or study_config["Algorithm"] in CheckAlgos): - logging.fatal("Algorithm provided is unknow : " + str(study_config["Algorithm"]) + - "\n You can choose between : " + str(AssimAlgos)+" "+str(CheckAlgos)) - sys.exit(1) + raise ValueError("\n\n Algorithm provided is unknow : " + str(study_config["Algorithm"]) + + "\n You can choose between : " + str(AssimAlgos)+" "+str(CheckAlgos) + "\n") # Debug if "Debug" not in study_config: @@ -68,17 +63,15 @@ def check_study(study_config): repertory = study_config["Repertory"] check_repertory = True if not os.path.isabs(repertory): - logging.fatal("Study repertory should be an absolute path") - logging.fatal("Repertory provided is %s" % repertory) - sys.exit(1) + raise ValueError("\n\n Study repertory should be an absolute path\n"+ + " Repertory provided is %s\n" % repertory) # Check if all the data is provided for key in AlgoDataRequirements[study_config["Algorithm"]]: if key not in study_config.keys(): - logging.fatal("Cannot found " + key + " in your study configuration !" + + raise ValueError("\n\nCannot find " + key + " in your study configuration !" + "\n This key is mandatory into a study with " + study_config["Algorithm"] + " algorithm." + - "\n " + study_config["Algorithm"] + " requirements are " + str(AlgoDataRequirements[study_config["Algorithm"]])) - sys.exit(1) + "\n " + study_config["Algorithm"] + " requirements are " + str(AlgoDataRequirements[study_config["Algorithm"]]) + "\n") # Data for key in study_config.keys(): @@ -97,16 +90,13 @@ def check_study(study_config): if "UserPostAnalysis" in study_config.keys(): analysis_config = study_config["UserPostAnalysis"] if "From" not in analysis_config: - logging.fatal("UserPostAnalysis found but From is not defined in the analysis configuration !") - sys.exit(1) + raise ValueError("\n\n UserPostAnalysis found but From is not defined \n in the analysis configuration!\n") else: if analysis_config["From"] not in AnalysisFromList: - logging.fatal("Analysis From defined in the study configuration does not have a correct type : " + str(analysis_config["From"]) - + "\n You can have : " + str(AnalysisFromList)) - sys.exit(1) + raise ValueError("\n\n Analysis From defined in the study configuration does not have a correct type : " + str(analysis_config["From"]) + + "\n You can have: " + str(AnalysisFromList) + "\n") if "Data" not in analysis_config: - logging.fatal("Analysis found but Data is not defined in the analysis configuration !") - sys.exit(1) + raise ValueError("\n\nAnalysis found but Data is not defined in the analysis configuration!\n") if analysis_config["From"] == "Script": check_file_name = "" @@ -115,84 +105,68 @@ def check_study(study_config): else: check_file_name = analysis_config["Data"] if not os.path.exists(check_file_name): - logging.fatal("A script file cannot be found") - logging.fatal("File is %s" % check_file_name) - sys.exit(1) + raise ValueError("\n\n The script file cannot be found for UserPostAnalysis,\n please check its availability.\n"+ + " The given user file is:\n %s\n" % check_file_name) # Check observers if "Observers" in study_config.keys(): for obs_var in study_config["Observers"]: # Check du type if not isinstance(study_config["Observers"][obs_var], type({})): - logging.fatal("An observer description has to be a Python dictionary") - logging.fatal("Observer is %s" % obs_var) - sys.exit(1) + raise ValueError("\n\n An observer description has to be a Python dictionary\n"+ + " Observer is %s\n" % obs_var) if "nodetype" not in study_config["Observers"][obs_var].keys(): - logging.fatal("An observer description must provide a nodetype") - logging.fatal("Observer is %s" % obs_var) - sys.exit(1) + raise ValueError("\n\n An observer description must provide a nodetype\n"+ + " Observer is %s\n" % obs_var) nodetype = study_config["Observers"][obs_var]["nodetype"] if not isinstance(study_config["Observers"][obs_var]["nodetype"], type("")): - logging.fatal("An observer nodetype description must be a string") - logging.fatal("Observer is %s" % obs_var) - sys.exit(1) + raise ValueError("\n\n An observer nodetype description must be a string\n"+ + " Observer is %s\n" % obs_var) if nodetype != "String" and nodetype != "Script": - logging.fatal("An observer nodetype must be equal to 'String' or 'Script'") - logging.fatal("Observer is %s" % obs_var) - sys.exit(1) + raise ValueError("\n\n An observer nodetype must be equal to 'String' or 'Script'\n"+ + " Observer is %s\n" % obs_var) if nodetype == "String": if "String" not in study_config["Observers"][obs_var].keys(): - logging.fatal("An observer with nodetype String must provide a String") - logging.fatal("Observer is %s" % obs_var) - sys.exit(1) + raise ValueError("\n\n An observer with nodetype String must provide a String\n"+ + " Observer is %s\n" % obs_var) if not isinstance(study_config["Observers"][obs_var]["String"], type("")): - logging.fatal("An observer String description must be a string") - logging.fatal("Observer is %s" % obs_var) - sys.exit(1) + raise ValueError("\n\n An observer String description must be a string\n"+ + " Observer is %s\n" % obs_var) if nodetype == "Script": if "Script" not in study_config["Observers"][obs_var].keys(): - logging.fatal("An observer with nodetype Script provide a Script") - logging.fatal("Observer is %s" % obs_var) - sys.exit(1) + raise ValueError("\n\n An observer with nodetype Script provide a Script\n"+ + " Observer is %s\n" % obs_var) if not isinstance(study_config["Observers"][obs_var]["Script"], type("")): - logging.fatal("An observer Script description must be a string") - logging.fatal("Observer is %s" % obs_var) - sys.exit(1) + raise ValueError("\n\n An observer Script description must be a string\n"+ + " Observer is %s\n" % obs_var) if "scheduler" in study_config["Observers"][obs_var].keys(): if not isinstance(study_config["Observers"][obs_var]["scheduler"], type("")): - logging.fatal("An observer scheduler description must be a string") - logging.fatal("Observer is %s" % obs_var) - sys.exit(1) + raise ValueError("\n\n An observer scheduler description must be a string\n"+ + " Observer is %s\n" % obs_var) def check_variables(name, study_config): if name not in study_config.keys(): - logging.fatal("%s not found in your study configuration!" % name) - sys.exit(1) + raise ValueError("\n\n %s not found in your study configuration!\n" % name) variable_config = study_config[name] if "Order" not in variable_config.keys(): - logging.fatal("Order not found in the %s configuration!" % name) - sys.exit(1) + raise ValueError("\n\n Order not found in the %s configuration!\n" % name) list_of_variables = variable_config["Order"] if not isinstance(list_of_variables, type([])): - logging.fatal("Order sould be a list in the %s configuration!" % name) - sys.exit(1) + raise ValueError("\n\n Order sould be a list in the %s configuration!\n" % name) if len(list_of_variables) < 1: - logging.fatal("Order should contain one or more names in the %s configuration!" % name) - sys.exit(1) + raise ValueError("\n\nOrder should contain one or more names in the %s configuration!\n" % name) for var in list_of_variables: if var not in variable_config.keys(): - logging.fatal("Variable %s not found in the %s configuration!" % name) - sys.exit(1) + raise ValueError("\n\n Variable %s not found in the %s configuration!\n" % name) value = variable_config[var] try: value = int(value) except: - loggind.fatal("Variable %s value cannot be converted in an integer in the %s configuration!" % name) - sys.exit(1) + raise ValueError("\n\n Variable %s value cannot be converted in an integer \n in the %s configuration!\n" % name) def check_data(data_name, data_config, repertory_check=False, repertory=""): @@ -202,25 +176,20 @@ def check_data(data_name, data_config, repertory_check=False, repertory=""): data_name_from = "From" if data_name_data not in data_config: - logging.fatal(data_name +" found but " + data_name_data +" is not defined in the study configuration !") - sys.exit(1) + raise ValueError("\n\n" + data_name +" found but " + data_name_data +" is not defined in the study configuration !\n") if data_name_type not in data_config: - logging.fatal(data_name +" found but " + data_name_type +" is not defined in the study configuration !") - sys.exit(1) + raise ValueError("\n\n" + data_name +" found but " + data_name_type +" is not defined in the study configuration !\n") else: if data_config[data_name_type] not in AssimType[data_name]: - logging.fatal(data_name_type + " of " + data_name + " defined in the study configuration does not have a correct type : " + str(data_config[data_name_type]) - + "\n You can have : " + str(AssimType[data_name])) - sys.exit(1) + raise ValueError("\n\n" + data_name_type + " of " + data_name + " defined in the study configuration does not have a correct type : " + str(data_config[data_name_type]) + + "\n You can have : " + str(AssimType[data_name]) + "\n") if data_name_from not in data_config: - logging.fatal(data_name + " found but " + data_name_from + " is not defined in the study configuration !") - sys.exit(1) + raise ValueError("\n\n" + data_name + " found but " + data_name_from + " is not defined in the study configuration !\n") else: if data_config[data_name_from] not in FromNumpyList[data_config[data_name_type]]: - logging.fatal(data_name_from + " of " + data_name + " defined in the study configuration does not have a correct value : " + str(data_config[data_name_from]) - + "\n You can have : " + str(FromNumpyList[data_config[data_name_type]])) - sys.exit(1) + raise ValueError("\n\n" + data_name_from + " of " + data_name + " defined in the study configuration does not have a correct value : " + str(data_config[data_name_from]) + + "\n You can have : " + str(FromNumpyList[data_config[data_name_type]]) + "\n") # Check des fichiers from_type = data_config["From"] @@ -231,9 +200,7 @@ def check_data(data_name, data_config, repertory_check=False, repertory=""): else: check_file_name = data_config["Data"] if not os.path.exists(check_file_name): - logging.fatal("A script file cannot be found") - logging.fatal("File is %s" % check_file_name) - sys.exit(1) + raise ValueError("\n\n The script file cannot be found for the \"%s\" keyword, please \n check its availability. The given user file is:\n %s\n"%(from_type,check_file_name)) elif from_type == "FunctionDict": FunctionDict = data_config["Data"] for FunctionName in FunctionDict["Function"]: @@ -243,9 +210,7 @@ def check_data(data_name, data_config, repertory_check=False, repertory=""): else: check_file_name = FunctionDict["Script"][FunctionName] if not os.path.exists(check_file_name): - logging.fatal("A script file cannot be found") - logging.fatal("File is %s" % check_file_name) - sys.exit(1) + raise ValueError("\n\n The script file cannot be found for the \"%s\" keyword, please \n check its availability. The given user file is:\n %s\n"%(from_type,check_file_name)) elif from_type == "ScriptWithSwitch": ScriptWithSwitch = data_config["Data"] for FunctionName in ScriptWithSwitch["Function"]: @@ -255,9 +220,7 @@ def check_data(data_name, data_config, repertory_check=False, repertory=""): else: check_file_name = ScriptWithSwitch["Script"][FunctionName] if not os.path.exists(check_file_name): - logging.fatal("A script file cannot be found") - logging.fatal("File is %s" % check_file_name) - sys.exit(1) + raise ValueError("\n\n The script file cannot be found for the \"%s\" keyword, please \n check its availability. The given user file is:\n %s\n"%(from_type,check_file_name)) elif from_type == "ScriptWithFunctions": ScriptWithFunctions = data_config["Data"] for FunctionName in ScriptWithFunctions["Function"]: @@ -267,6 +230,4 @@ def check_data(data_name, data_config, repertory_check=False, repertory=""): else: check_file_name = ScriptWithFunctions["Script"][FunctionName] if not os.path.exists(check_file_name): - logging.fatal("A script file cannot be found") - logging.fatal("File is %s" % check_file_name) - sys.exit(1) + raise ValueError("\n\n The script file cannot be found for the \"%s\" keyword, please \n check its availability. The given user file is:\n %s\n"%(from_type,check_file_name)) diff --git a/src/daSalome/daYacsSchemaCreator/methods.py b/src/daSalome/daYacsSchemaCreator/methods.py index f686caf..7cf84ea 100644 --- a/src/daSalome/daYacsSchemaCreator/methods.py +++ b/src/daSalome/daYacsSchemaCreator/methods.py @@ -42,9 +42,7 @@ def create_yacs_proc(study_config): catalogAd = runtime.loadCatalog("proc", os.environ["ADAO_ROOT_DIR"] + "/share/salome/resources/adao/ADAOSchemaCatalog.xml") runtime.addCatalog(catalogAd) except: - logging.fatal("Exception in loading DataAssim YACS catalog") - traceback.print_exc() - sys.exit(1) + raise ValueError("Exception in loading ADAO YACS Schema catalog") # Starting creating proc proc = runtime.createProc("proc") @@ -407,21 +405,17 @@ def create_yacs_proc(study_config): try: script_str= open(script_filename, 'r') except: - logging.fatal("Exception in opening function script file : " + script_filename) - traceback.print_exc() - sys.exit(1) + raise ValueError("Exception in opening function script file: " + script_filename) node_script = "#-*-coding:iso-8859-1-*-\n" node_script += "import sys, os \n" - if base_repertory != "": - node_script += "filepath = \"" + base_repertory + "\"\n" - else: - node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" + node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n" node_script += " sys.path.insert(0,filepath)\n" node_script += script_str.read() opt_script_nodeOO.setScript(node_script) opt_script_nodeOO.edAddInputPort("computation", t_param_input) opt_script_nodeOO.edAddOutputPort("result", t_param_output) + elif data_config["Type"] == "Function" and data_config["From"] == "ScriptWithSwitch": # Get script ScriptWithSwitch = data_config["Data"] @@ -430,7 +424,6 @@ def create_yacs_proc(study_config): # We currently support only one file script_filename = ScriptWithSwitch["Script"][FunctionName] break - # We create a new pyscript node opt_script_nodeOO = runtime.createScriptNode("", "FunctionNodeOO") if repertory: @@ -438,15 +431,10 @@ def create_yacs_proc(study_config): try: script_str= open(script_filename, 'r') except: - logging.fatal("Exception in opening function script file : " + script_filename) - traceback.print_exc() - sys.exit(1) + raise ValueError("Exception in opening function script file: " + script_filename) node_script = "#-*-coding:iso-8859-1-*-\n" node_script += "import sys, os \n" - if base_repertory != "": - node_script += "filepath = \"" + base_repertory + "\"\n" - else: - node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" + node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n" node_script += " sys.path.insert(0,filepath)\n" node_script += script_str.read() @@ -469,15 +457,10 @@ def create_yacs_proc(study_config): try: script_str= open(script_filename, 'r') except: - logging.fatal("Exception in opening function script file : " + script_filename) - traceback.print_exc() - sys.exit(1) + raise ValueError("Exception in opening function script file: " + script_filename) node_script = "#-*-coding:iso-8859-1-*-\n" node_script += "import sys, os, numpy, logging\n" - if base_repertory != "": - node_script += "filepath = \"" + base_repertory + "\"\n" - else: - node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" + node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n" node_script += " sys.path.insert(0,filepath)\n" node_script += """# ==============================================\n""" @@ -561,15 +544,10 @@ def create_yacs_proc(study_config): try: script_str= open(script_filename, 'r') except: - logging.fatal("Exception in opening function script file : " + script_filename) - traceback.print_exc() - sys.exit(1) + raise ValueError("Exception in opening function script file: " + script_filename) node_script = "#-*-coding:iso-8859-1-*-\n" node_script += "import sys, os \n" - if base_repertory != "": - node_script += "filepath = \"" + base_repertory + "\"\n" - else: - node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" + node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n" node_script += " sys.path.insert(0,filepath)\n" node_script += script_str.read() @@ -592,21 +570,17 @@ def create_yacs_proc(study_config): try: script_str= open(script_filename, 'r') except: - logging.fatal("Exception in opening function script file : " + script_filename) - traceback.print_exc() - sys.exit(1) + raise ValueError("Exception in opening function script file: " + script_filename) node_script = "#-*-coding:iso-8859-1-*-\n" node_script += "import sys, os \n" - if base_repertory != "": - node_script += "filepath = \"" + base_repertory + "\"\n" - else: - node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" + node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n" node_script += " sys.path.insert(0,filepath)\n" node_script += script_str.read() opt_script_nodeEM.setScript(node_script) opt_script_nodeEM.edAddInputPort("computation", t_param_input) opt_script_nodeEM.edAddOutputPort("result", t_param_output) + elif data_config["Type"] == "Function" and data_config["From"] == "ScriptWithFunctions": # Get script ScriptWithFunctions = data_config["Data"] @@ -615,7 +589,6 @@ def create_yacs_proc(study_config): # We currently support only one file script_filename = ScriptWithFunctions["Script"][FunctionName] break - # We create a new pyscript node opt_script_nodeEM = runtime.createScriptNode("", "FunctionNodeEM") if repertory: @@ -623,15 +596,10 @@ def create_yacs_proc(study_config): try: script_str= open(script_filename, 'r') except: - logging.fatal("Exception in opening function script file : " + script_filename) - traceback.print_exc() - sys.exit(1) + raise ValueError("Exception in opening function script file: " + script_filename) node_script = "#-*-coding:iso-8859-1-*-\n" node_script += "import sys, os, numpy, logging\n" - if base_repertory != "": - node_script += "filepath = \"" + base_repertory + "\"\n" - else: - node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" + node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n" node_script += " sys.path.insert(0,filepath)\n" node_script += script_str.read() @@ -851,15 +819,10 @@ def create_yacs_proc(study_config): try: analysis_file = open(analysis_file_name, 'r') except: - logging.fatal("Exception in opening analysis file : " + str(analysis_config["Data"])) - traceback.print_exc() - sys.exit(1) + raise ValueError("Exception in opening analysis file: " + str(analysis_config["Data"])) node_script = "#-*-coding:iso-8859-1-*-\n" node_script += "import sys, os \n" - if base_repertory != "": - node_script += "filepath = \"" + base_repertory + "\"\n" - else: - node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n" + node_script += "filepath = \"" + os.path.dirname(analysis_file_name) + "\"\n" node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n" node_script += " sys.path.insert(0,filepath)\n" node_script += default_script diff --git a/src/daSalome/daYacsSchemaCreator/run.py b/src/daSalome/daYacsSchemaCreator/run.py index df1c189..ea39d45 100644 --- a/src/daSalome/daYacsSchemaCreator/run.py +++ b/src/daSalome/daYacsSchemaCreator/run.py @@ -33,13 +33,10 @@ def create_schema(config_file, yacs_schema_filename): try: execfile(config_file) except: - logging.fatal("Exception in loading " + config_file) - traceback.print_exc() - sys.exit(1) + raise ValueError("\n\n Exception in loading %s"%config_file) if "study_config" not in locals(): - logging.fatal("Cannot found study_config in " + str(config_file)) - sys.exit(1) + raise ValueError("\n\n Cannot found study_config in %s\n"%str(config_file)) else: globals()['study_config'] = locals()['study_config'] -- 2.39.2