#!/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 stat 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() os.chmod(os.path.join(ROOT_DIR, env_file_name), stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IWUSR | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) 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)