#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2017 CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
# --- names of tags in XML configuration file
appli_tag = "application"
+prereq_tag = "prerequisites"
context_tag = "context"
sha1_collect_tag = "sha1_collections"
+system_conf_tag = "system_conf"
modules_tag = "modules"
module_tag = "module"
samples_tag = "samples"
extra_tests_tag = "extra_tests"
extra_test_tag = "extra_test"
resources_tag = "resources"
+env_modules_tag = "env_modules"
+env_module_tag = "env_module"
# --- names of attributes in XML configuration file
nam_att = "name"
self.config["modules"] = []
self.config["guimodules"] = []
self.config["extra_tests"] = []
+ self.config["env_modules"] = []
parser = xml.sax.make_parser()
parser.setContentHandler(self)
parser.parse(fileName)
def startElement(self, name, attrs):
self.space.append(name)
self.current = None
+ # --- if we are analyzing "prerequisites" element then store its "path" attribute
+ if self.space == [appli_tag, prereq_tag] and path_att in attrs.getNames():
+ self.config["prereq_path"] = attrs.getValue( path_att )
+ pass
# --- if we are analyzing "context" element then store its "path" attribute
if self.space == [appli_tag, context_tag] and path_att in attrs.getNames():
self.config["context_path"] = attrs.getValue( path_att )
if self.space == [appli_tag, sha1_collect_tag] and path_att in attrs.getNames():
self.config["sha1_collect_path"] = attrs.getValue( path_att )
pass
+ # --- if we are analyzing "system_conf" element then store its "path" attribute
+ if self.space == [appli_tag, system_conf_tag] and path_att in attrs.getNames():
+ self.config["system_conf_path"] = attrs.getValue( path_att )
+ pass
# --- if we are analyzing "resources" element then store its "path" attribute
if self.space == [appli_tag, resources_tag] and path_att in attrs.getNames():
self.config["resources_path"] = attrs.getValue( path_att )
self.config["guimodules"].append(nam)
pass
pass
+ # --- if we are analyzing "env_module" element then store its "name" attribute
+ elif self.space == [appli_tag, env_modules_tag, env_module_tag] and \
+ nam_att in attrs.getNames():
+ nam = attrs.getValue( nam_att )
+ self.config["env_modules"].append(nam)
+ pass
# --- if we are analyzing "extra_test" element then store its "name" and "path" attributes
elif self.space == [appli_tag,extra_tests_tag,extra_test_tag] and \
nam_att in attrs.getNames() and \
print inst.args
print "Configure parser: error in configuration file %s" % filename
pass
- except:
+ except Exception as e:
print "Configure parser: Error : can not read configuration file %s, check existence and rights" % filename
+ print(e)
pass
if verbose:
'getAppliPath.py',
'kill_remote_containers.py',
'runRemote.sh',
- 'salome',
+ '.salome_run',
'update_catalogs.py',
'.bashrc',
):
pass
+ # Copy salome script
+ salome_script = open(os.path.join(appliskel_dir, "salome")).read()
+ salome_file = os.path.join(home_dir, "salome")
+ try:
+ os.remove(salome_file)
+ except:
+ pass
+ env_modules = [m.encode('utf8') for m in _config.get('env_modules', [])]
+ with open(salome_file, 'w') as fd:
+ fd.write(salome_script.replace('MODULES = []', 'MODULES = {}'.format(env_modules)))
+ os.chmod(salome_file, 0o755)
+
+
# Add .salome-completion.sh file
shutil.copyfile(os.path.join(appliskel_dir, ".salome-completion.sh"),
os.path.join(home_dir, ".salome-completion.sh"))
# Creation of env.d directory
virtual_salome.mkdir(os.path.join(home_dir,'env.d'))
+ if _config.has_key("prereq_path") and os.path.isfile(_config["prereq_path"]):
+ shutil.copyfile(_config["prereq_path"],
+ os.path.join(home_dir, 'env.d', 'envProducts.sh'))
+ pass
+ else:
+ print "WARNING: prerequisite file does not exist"
+ pass
+
if _config.has_key("context_path") and os.path.isfile(_config["context_path"]):
shutil.copyfile(_config["context_path"],
os.path.join(home_dir, 'env.d', 'envProducts.cfg'))
os.path.join(home_dir, 'sha1_collections.txt'))
pass
else:
- print "WARNING: context file does not exist"
+ print "WARNING: sha1 collections file does not exist"
pass
+ if _config.has_key("system_conf_path") and os.path.isfile(_config["system_conf_path"]):
+ shutil.copyfile(_config["system_conf_path"],
+ os.path.join(home_dir, 'env.d', 'envConfSystem.sh'))
+ pass
+
+ # Create environment file: configSalome.sh
+ with open(os.path.join(home_dir, 'env.d', 'configSalome.sh'),'w') as f:
+ for module in _config.get("modules", []):
+ command = 'export '+ module + '_ROOT_DIR=${HOME}/${APPLI}\n'
+ f.write(command)
+ pass
+ if _config.has_key("samples_path"):
+ command = 'export DATA_DIR=' + _config["samples_path"] +'\n'
+ f.write(command)
+ pass
+ if _config.has_key("resources_path") and os.path.isfile(_config["resources_path"]):
+ command = 'export USER_CATALOG_RESOURCES_FILE=' + os.path.abspath(_config["resources_path"]) +'\n'
+ f.write(command)
+
# Create configuration file: configSalome.cfg
with open(os.path.join(home_dir, 'env.d', 'configSalome.cfg'),'w') as f:
command = "[SALOME ROOT_DIR (modules) Configuration]\n"
command = 'USER_CATALOG_RESOURCES_FILE=' + os.path.abspath(_config["resources_path"]) +'\n'
f.write(command)
+
+ # Create environment file: configGUI.sh
+ with open(os.path.join(home_dir, 'env.d', 'configGUI.sh'),'w') as f:
+ command = """export SalomeAppConfig=${HOME}/${APPLI}
+export SUITRoot=${HOME}/${APPLI}/share/salome
+export DISABLE_FPE=1
+export MMGT_REENTRANT=1
+"""
+ f.write(command)
+
# Create configuration file: configGUI.cfg
with open(os.path.join(home_dir, 'env.d', 'configGUI.cfg'),'w') as f:
command = """[SALOME GUI Configuration]