From: Jean-Philippe ARGAUD Date: Wed, 31 Jan 2018 14:53:29 +0000 (+0100) Subject: Conversion and YACS execution corrections X-Git-Tag: V8_5_0rc1~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d01de9a9cf59ac6193619348737eb23b8f93b740;p=modules%2Fadao.git Conversion and YACS execution corrections --- diff --git a/bin/AdaoYacsSchemaCreator.py b/bin/AdaoYacsSchemaCreator.py index 587896b..66e3dc1 100644 --- a/bin/AdaoYacsSchemaCreator.py +++ b/bin/AdaoYacsSchemaCreator.py @@ -32,17 +32,16 @@ logging.debug("-- Starting AdaoYacsSchemaCreator --") # Check some basics variables if "ADAO_ROOT_DIR" not in os.environ: - logging.fatal("You have to define ADAO_ROOT_DIR") - sys.exit(1) + logging.fatal("You have to define ADAO_ROOT_DIR") + sys.exit(1) try: - from daYacsSchemaCreator.run import * - from daYacsSchemaCreator.help_methods import * -except: - logging.fatal("Import of ADAO python modules failed !" + - "\n add ADAO python installation directory in your PYTHONPATH") - traceback.print_exc() - sys.exit(1) + from daYacsSchemaCreator import run +except ImportError as e: + logging.fatal("\n Import of YACS schema creator module failed, the error message is:\n" + + "\n %s\n"%(e,) + + "\n Add its installation directory in your PYTHONPATH.\n") + sys.exit(1) # Parse arguments from argparse import ArgumentParser @@ -52,4 +51,4 @@ my_parser.add_argument('config_file') my_parser.add_argument('yacs_schema_filename') args = my_parser.parse_args() -create_schema_from_file(args.config_file, args.yacs_schema_filename) +run.create_schema_from_file(args.config_file, args.yacs_schema_filename) diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index 62cc351..a127da6 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -965,9 +965,9 @@ class AlgorithmAndParameters(object): xmlLoader.registerProcCataLoader() try: catalogAd = r.loadCatalog("proc", os.path.abspath(FileName)) + r.addCatalog(catalogAd) except: pass - r.addCatalog(catalogAd) try: p = xmlLoader.load(os.path.abspath(FileName)) @@ -2094,7 +2094,11 @@ class _SCDViewer(GenericCaseViewer): __ExecVariables = {} # Necessaire pour recuperer la variable exec("\n".join(self._lineSerie), __ExecVariables) study_config = __ExecVariables['study_config'] - self.__hasAlgorithm = bool(study_config['Algorithm']) + # Pour Python 3 : self.__hasAlgorithm = bool(study_config['Algorithm']) + if 'Algorithm' in study_config: + self.__hasAlgorithm = True + else: + self.__hasAlgorithm = False if not self.__hasAlgorithm and \ "AlgorithmParameters" in study_config and \ isinstance(study_config['AlgorithmParameters'], dict) and \ diff --git a/src/daSalome/daYacsSchemaCreator/run.py b/src/daSalome/daYacsSchemaCreator/run.py index 7a5740b..12b403f 100644 --- a/src/daSalome/daYacsSchemaCreator/run.py +++ b/src/daSalome/daYacsSchemaCreator/run.py @@ -26,6 +26,7 @@ import sys import os import traceback import logging +import tempfile from daYacsSchemaCreator.methods import * from daYacsSchemaCreator.help_methods import * @@ -34,7 +35,8 @@ def create_schema(config_file, config_content, yacs_schema_filename): if config_file is not None and config_content is None: # Import config_file try: - exec(compile(open(config_file).read(), config_file, 'exec')) + (fd, filename) = tempfile.mkstemp() + exec(compile(open(config_file).read(), filename, 'exec')) except Exception as e: if isinstance(e, SyntaxError): msg = "at %s: %s"%(e.offset, e.text) else: msg = "" @@ -42,11 +44,12 @@ def create_schema(config_file, config_content, yacs_schema_filename): elif config_file is None and config_content is not None: # Import config_content try: - exec(compile(config_content, None, 'exec')) + (fd, filename) = tempfile.mkstemp() + exec(compile(config_content, filename, 'exec')) except Exception as e: if isinstance(e, SyntaxError): msg = "at %s: %s"%(e.offset, e.text) else: msg = "" - raise ValueError("\n\nexception in loading the DIC config content\n\nThe following error occurs:\n\n%s %s\n\nSee also the potential messages, which can show the origin of the above error, in the launching terminal.\n"%(str(e),msg)) + raise ValueError("\n\nexception in loading the config content\n\nThe following error occurs:\n\n%s %s\n\nSee also the potential messages, which can show the origin of the above error, in the launching terminal.\n"%(str(e),msg)) else: raise ValueError("Error in schema creation, file or content has to be given")