Salome HOME
Permet d'ajouter un code d'analyse à partir d'un fichier
[modules/adao.git] / src / daSalome / daYacsSchemaCreator / run.py
1 #!/usr/bin/python
2 #-*-coding:iso-8859-1-*-
3 #  Copyright (C) 2008-2009  EDF R&D
4 #
5 #  This library is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU General Public
7 #  License as published by the Free Software Foundation; either
8 #  version 2.1 of the License.
9 #
10 #  This library is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 #  Lesser General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Lesser General Public
16 #  License along with this library; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # --
20 # Author : André RIBES (EDF R&D)
21 # --
22
23 import sys
24 import os
25 import traceback
26 import logging
27 from optparse import OptionParser
28 from daYacsSchemaCreator.methods import *
29 from daYacsSchemaCreator.help_methods import *
30
31 def create_schema(config_file, yacs_schema_filename):
32
33   # Import config_file
34   try:
35     execfile(config_file)
36   except:
37     logging.fatal("Exception in loading " + config_file)
38     traceback.print_exc()
39     sys.exit(1)
40
41   if "study_config" not in locals():
42     logging.fatal("Cannot found study_config in " + str(config_file))
43     sys.exit(1)
44   else:
45     globals()['study_config'] = locals()['study_config']
46
47   check_study(study_config)
48   proc = create_yacs_proc(study_config)
49   write_yacs_proc(proc, yacs_schema_filename)