From f166b1311a1df99d10f6e8b55d4095715be7e02e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9?= Date: Wed, 21 Apr 2010 16:39:34 +0200 Subject: [PATCH] Ajout de l'executable --- Makefile.am | 2 +- bin/DatassimYacsSchemaCreator.py | 54 +++++++++++++++++++ bin/Makefile.am | 5 ++ configure.ac | 1 + .../{YacsSchemaCreator.py => run.py} | 28 +--------- 5 files changed, 62 insertions(+), 28 deletions(-) create mode 100644 bin/DatassimYacsSchemaCreator.py create mode 100644 bin/Makefile.am rename src/daSalome/daYacsSchemaCreator/{YacsSchemaCreator.py => run.py} (69%) mode change 100755 => 100644 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/run.py old mode 100755 new mode 100644 similarity index 69% rename from src/daSalome/daYacsSchemaCreator/YacsSchemaCreator.py rename to src/daSalome/daYacsSchemaCreator/run.py index cb78d76..e761892 --- a/src/daSalome/daYacsSchemaCreator/YacsSchemaCreator.py +++ b/src/daSalome/daYacsSchemaCreator/run.py @@ -28,26 +28,7 @@ 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] +def create_schema(config_file, yacs_schema_filename): # Import config_file try: @@ -63,13 +44,6 @@ def main(): 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() -- 2.39.2