Salome HOME
sat #8594 : extension des logs de sat log --last_compile au make check
[tools/sat.git] / src / internal_config / create_appli.py.for_bin_packages.template
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 #  Copyright (C) 2010-2012  CEA/DEN
4 #
5 #  This library is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU Lesser 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 import os
20 import stat
21 import subprocess
22 import shutil
23
24 ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
25 dir_bin_name = TO BE FILLED 1
26
27 appli_config_name = "appli_config.xml"
28 appli_config_contain = '''<application>
29 <prerequisites path="env_launch.sh"/>
30 <resources path="CatalogResources.xml"/>
31 <modules>
32 TO BE FILLED 2</modules>
33 </application>
34 '''
35 # Write the appli_config.xml file
36 appli_config_stream = open(os.path.join(ROOT_DIR, appli_config_name), "w")
37 appli_config_stream.write(appli_config_contain)
38 appli_config_stream.close()
39
40 # Put the absolute path of the application in the env_launch file
41 env_file_name = "env_launch.sh"
42 env_file_save_name = "env_launch.sh_save"
43 shutil.move(os.path.join(ROOT_DIR, env_file_name), os.path.join(ROOT_DIR, env_file_save_name))
44 env_file_save_stream = open(os.path.join(ROOT_DIR, env_file_save_name), "r")
45 env_file_stream = open(os.path.join(ROOT_DIR, env_file_name), "w")
46 for line in env_file_save_stream.readlines():
47         if 'export out_dir_Path=' in line:
48                 line_to_write = 'export out_dir_Path="' + ROOT_DIR + '"\n'
49         else:
50                 line_to_write = line
51         env_file_stream.write(line_to_write)
52
53 for stream in [env_file_save_stream, env_file_stream]:
54         stream.close()
55
56 os.chmod(os.path.join(ROOT_DIR, env_file_name),
57          stat.S_IRUSR |
58          stat.S_IRGRP |
59          stat.S_IROTH |
60          stat.S_IWUSR |
61          stat.S_IXUSR |
62          stat.S_IXGRP |
63          stat.S_IXOTH)
64
65 command = "python " + os.path.join(ROOT_DIR, dir_bin_name, "KERNEL", "bin", "salome", "appli_gen.py") + " --prefix=APPLI --config=" + appli_config_name
66 subprocess.call(command, shell=True)