From: Serge Rehbinder Date: Tue, 7 Feb 2017 13:06:16 +0000 (+0100) Subject: sat package: add a script that can produce an EDF appli in the binary packages X-Git-Tag: 5.0.0a1~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bf2005f62e0b0c9dc07c847d72c7c4fc4e80330c;p=tools%2Fsat.git sat package: add a script that can produce an EDF appli in the binary packages --- diff --git a/commands/package.py b/commands/package.py index f386e44..c476b2f 100644 --- a/commands/package.py +++ b/commands/package.py @@ -245,6 +245,46 @@ def produce_relative_env_files(config, return filepath +def product_appli_creation_script(config, + logger, + file_dir, + binaries_dir_name): + '''Create a script that can produce an application (EDF style) in the binary + package. + + :param config Config: The global configuration. + :param logger Logger: the logging instance + :param file_dir str: the directory where to put the file + :param binaries_dir_name str: the name of the repository where the binaries + are, in the archive. + :return: the path of the produced script file + :rtype: Str + ''' + template_name = "create_appli.py.for_bin_packages.template" + template_path = os.path.join(config.VARS.internal_dir, template_name) + text_to_fill = open(template_path, "r").read() + text_to_fill = text_to_fill.replace("TO BE FILLED 1", + '"' + binaries_dir_name + '"') + + text_to_add = "" + for product_name in config.APPLICATION.products: + product_info = src.product.get_product_config(config, product_name) + if src.product.product_is_SALOME(product_info): + line_to_add = ("") + text_to_add += line_to_add + "\n" + + filled_text = text_to_fill.replace("TO BE FILLED 2", text_to_add) + + tmp_file_path = os.path.join(file_dir, "create_appli.py") + ff = open(tmp_file_path, "w") + ff.write(filled_text) + ff.close() + + return tmp_file_path def binary_package(config, logger, options, tmp_working_dir): '''Prepare a dictionary that stores all the needed directories and files to @@ -325,7 +365,15 @@ def binary_package(config, logger, options, tmp_working_dir): binaries_dir_name) d_products["environment file"] = (env_file, "env_launch.sh") - + + # And provide a script for the creation of an application EDF style + appli_script = product_appli_creation_script(config, + logger, + tmp_working_dir, + binaries_dir_name) + + d_products["appli script"] = (env_file, appli_script) + return d_products def source_package(sat, config, logger, options, tmp_working_dir): diff --git a/src/internal_config/create_appli.py.for_bin_packages.template b/src/internal_config/create_appli.py.for_bin_packages.template new file mode 100644 index 0000000..9694be5 --- /dev/null +++ b/src/internal_config/create_appli.py.for_bin_packages.template @@ -0,0 +1,56 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- +# Copyright (C) 2010-2012 CEA/DEN +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser 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 + +import os +import subprocess +import shutil + +ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) +dir_bin_name = TO BE FILLED 1 + +appli_config_name = "appli_config.xml" +appli_config_contain = ''' + + + +TO BE FILLED 2 + +''' +# Write the appli_config.xml file +appli_config_stream = open(os.path.join(ROOT_DIR, appli_config_name), "w") +appli_config_stream.write(appli_config_contain) +appli_config_stream.close() + +# Put the absolute path of the application in the env_launch file +env_file_name = "env_launch.sh" +env_file_save_name = "env_launch.sh_save" +shutil.move(os.path.join(ROOT_DIR, env_file_name), os.path.join(ROOT_DIR, env_file_save_name)) +env_file_save_stream = open(os.path.join(ROOT_DIR, env_file_save_name), "r") +env_file_stream = open(os.path.join(ROOT_DIR, env_file_name), "w") +for line in env_file_save_stream.readlines(): + if 'export out_dir_Path=' in line: + line_to_write = 'export out_dir_Path="' + ROOT_DIR + '"\n' + else: + line_to_write = line + env_file_stream.write(line_to_write) + +for stream in [env_file_save_stream, env_file_stream]: + stream.close() + +command = "python " + os.path.join(ROOT_DIR, dir_bin_name, "KERNEL", "bin", "salome", "appli_gen.py") + " --prefix=APPLI --config=" + appli_config_name +subprocess.call(command, shell=True) \ No newline at end of file