From: André Date: Wed, 21 Apr 2010 14:39:34 +0000 (+0200) Subject: Ajout de l'executable X-Git-Tag: V6_4_0rc3~172 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f166b1311a1df99d10f6e8b55d4095715be7e02e;p=modules%2Fadao.git Ajout de l'executable --- diff --git a/Makefile.am b/Makefile.am index e3bb26d..1aa61a8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,3 @@ include $(top_srcdir)/adm_local/make_common_starter.am -SUBDIRS = idl resources src +SUBDIRS = idl resources src bin ACLOCAL_AMFLAGS = -I adm_local diff --git a/bin/DatassimYacsSchemaCreator.py b/bin/DatassimYacsSchemaCreator.py new file mode 100644 index 0000000..46e7d52 --- /dev/null +++ b/bin/DatassimYacsSchemaCreator.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +#-*-coding:iso-8859-1-*- +# Copyright (C) 2008-2009 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# -- +# Author : André RIBES (EDF R&D) +# -- + +import sys +import os +import traceback +import logging +logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s') + +print "-- Starting DatassimYacsSchemaCreator --" + +# Check some basics variables +if "DATASSIM_ROOT_DIR" not in os.environ: + logging.fatal("You have to define DATASSIM_ROOT_DIR") + sys.exit(1) + +try: + from daYacsSchemaCreator.run import * + from daYacsSchemaCreator.help_methods import * +except: + logging.fatal("Import of DATASSIM python modules failed !" + + "\n add DATASSIM python installation directory in your PYTHONPATH") + sys.exit(1) + +# Parse arguments +from optparse import OptionParser +usage = "usage: %prog [options] config_file yacs_schema_filename" +version="%prog 0.1" +my_parser = OptionParser(usage=usage, version=version) +(options, args) = my_parser.parse_args() +check_args(args) + +config_file = args[0] +yacs_schema_filename = args[1] +create_schema(config_file, yacs_schema_filename) diff --git a/bin/Makefile.am b/bin/Makefile.am new file mode 100644 index 0000000..a95e5c2 --- /dev/null +++ b/bin/Makefile.am @@ -0,0 +1,5 @@ +include $(top_srcdir)/adm_local/make_common_starter.am + +bin_SCRIPTS = DatassimYacsSchemaCreator.py + +EXTRA_DIST = DatassimYacsSchemaCreator.py diff --git a/configure.ac b/configure.ac index 53b02b0..5f48ce9 100644 --- a/configure.ac +++ b/configure.ac @@ -73,5 +73,6 @@ AC_CONFIG_FILES([ src/Makefile src/daComposant/Makefile src/daSalome/Makefile + bin/Makefile ]) AC_OUTPUT diff --git a/src/daSalome/daYacsSchemaCreator/YacsSchemaCreator.py b/src/daSalome/daYacsSchemaCreator/YacsSchemaCreator.py deleted file mode 100755 index cb78d76..0000000 --- a/src/daSalome/daYacsSchemaCreator/YacsSchemaCreator.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/python -#-*-coding:iso-8859-1-*- -# Copyright (C) 2008-2009 EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# -- -# Author : André RIBES (EDF R&D) -# -- - -import sys -import os -import traceback -import logging -from optparse import OptionParser -from daYacsSchemaCreator.methods import * -from daYacsSchemaCreator.help_methods import * - -# Variables globales -global my_parser - -# Init part -def init(): - - logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s') - usage = "usage: %prog [options] config_file yacs_schema_filename" - version="%prog 0.1" - global my_parser - my_parser = OptionParser(usage=usage, version=version) - -# Start application -def main(): - - print "-- Starting YacsSchemaCreator --" - (options, args) = my_parser.parse_args() - check_args(args) - config_file = args[0] - yacs_schema_filename = args[1] - - # Import config_file - try: - execfile(config_file) - except: - logging.fatal("Exception in loading " + config_file) - traceback.print_exc() - sys.exit(1) - - if "study_config" not in locals(): - logging.fatal("Cannot found study_config in " + str(config_file)) - sys.exit(1) - else: - globals()['study_config'] = locals()['study_config'] - - if "DATASSIM_ROOT_DIR" not in os.environ: - logging.fatal("You have to define DATASSIM_ROOT_DIR") - sys.exit(1) - - check_study(study_config) - proc = create_yacs_proc(study_config) - write_yacs_proc(proc, yacs_schema_filename) - -init() -main() diff --git a/src/daSalome/daYacsSchemaCreator/run.py b/src/daSalome/daYacsSchemaCreator/run.py new file mode 100644 index 0000000..e761892 --- /dev/null +++ b/src/daSalome/daYacsSchemaCreator/run.py @@ -0,0 +1,49 @@ +#!/usr/bin/python +#-*-coding:iso-8859-1-*- +# Copyright (C) 2008-2009 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# -- +# Author : André RIBES (EDF R&D) +# -- + +import sys +import os +import traceback +import logging +from optparse import OptionParser +from daYacsSchemaCreator.methods import * +from daYacsSchemaCreator.help_methods import * + +def create_schema(config_file, yacs_schema_filename): + + # Import config_file + try: + execfile(config_file) + except: + logging.fatal("Exception in loading " + config_file) + traceback.print_exc() + sys.exit(1) + + if "study_config" not in locals(): + logging.fatal("Cannot found study_config in " + str(config_file)) + sys.exit(1) + else: + globals()['study_config'] = locals()['study_config'] + + check_study(study_config) + proc = create_yacs_proc(study_config) + write_yacs_proc(proc, yacs_schema_filename)