# 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
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)
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))
__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 \
import os
import traceback
import logging
+import tempfile
from daYacsSchemaCreator.methods import *
from daYacsSchemaCreator.help_methods import *
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 = ""
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")