From: Serge Rehbinder Date: Fri, 29 Jan 2016 10:44:25 +0000 (+0100) Subject: Add software read in config X-Git-Tag: sprint-01~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=24bea8d054b6cbece77bca62b149416e8e61d933;p=tools%2Fsat.git Add software read in config --- diff --git a/data/distrib.pyconf b/data/distrib.pyconf deleted file mode 100644 index 18e6edd..0000000 --- a/data/distrib.pyconf +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python -#-*- coding:utf-8 -*- - -# distribution codes -# Code to use to replace the value returned by: lsb_release -si -# If no code is found an error will be raised. -DISTRIBUTIONS : -{ - "bullxServer": "BS" - "CentOS": "CO" - "Debian": "DB" - "Fedora": "FD" - "LinuxMint": "MN" - "Mageia": "MG" - "MandrivaLinux": "MD" - "RedHatEnterpriseServer": "RH" - "Ubuntu": "UB" - "openSUSE project":"OS" -} - -# versions substitution -# Code to use for release, to the replace value returned by: lsb_release -sr -# If no code is found the value is used. -VERSIONS : -{ - "DB": - { - "unstable": "sid" - "5.0": "05" - "4.0": "04" - "6.0.7" : "06" - "6.0.10": "06" - "7.1" : "07" - "7.5" : "07" - } - "MD": - { - "2008.0": "08" - "2010.0": "10" - "2010.1": "10" - "2010.2": "10" - "2007.1": "07" - "2006.0": "06" - "4" : "06" - } - "MG": - { - "3": "03" - "4": "04" - "5": "05" - "6": "06" - } - "CO": - { - "7.1.1503": "7.1" - } -} diff --git a/data/site.pyconf b/data/site.pyconf index 97135df..a155376 100644 --- a/data/site.pyconf +++ b/data/site.pyconf @@ -8,5 +8,13 @@ SITE : configPath : ["/home/salome/SPN_PRIVATE/sat5dev_Applications"] copy_prefix : "LOCAL_" } + prepare : + { + default_git_server : "http://default.git" + default_git_server_dev : "http://default_dev.git" + archive_dir : "/home/salome/ETC" + cvs_dir : "/test" + default_cvs_server : "http://default.cvs" + } } diff --git a/data/software_pyconf/softA.pyconf b/data/software_pyconf/softA.pyconf new file mode 100644 index 0000000..0a1f036 --- /dev/null +++ b/data/software_pyconf/softA.pyconf @@ -0,0 +1,36 @@ +SOFTWARE : +{ + softA : + { + name : "softA" + has_gui : "no" + compile_method : "cmake" # ou autotools, ou script + get_method : "git" # "archive", embedded", "native" "fixed" + cvs_info: + { + server : $SITE.prepare.default_cvs_server + module_base : $SITE.prepare.cvs_dir + $name + source : 'softA_SRC' + tag : '' + } + git_info: + { + repo : $SITE.prepare.default_git_server + $VARS.sep + $name + repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name + tag : $APPLICATION.default_version_to_download + } + archive_info: + { + archive_name : $SITE.prepare.archive_dir + $VARS.sep + $name + '.tar.gz' + } + environ : + { + "_LD_LIBRARY_PATH" : "${SOFT_ROOT_DIR}" + $VARS.sep + "lib" + "_PYTHONPATH" : ["${SOFT_ROOT_DIR}" + $VARS.sep + "lib" + "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR0}" + "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR1}"] + } + depend : [] + opt_depend : [] + } +} \ No newline at end of file diff --git a/data/software_pyconf/softB.pyconf b/data/software_pyconf/softB.pyconf new file mode 100644 index 0000000..3a34586 --- /dev/null +++ b/data/software_pyconf/softB.pyconf @@ -0,0 +1,36 @@ +SOFTWARE : +{ + softB : + { + name : "softB" + has_gui : "no" + compile_method : "cmake" # ou autotools, ou script + get_method : "git" # "archive", embedded", "native" "fixed" + cvs_info: + { + server : $SITE.prepare.default_cvs_server + module_base : $SITE.prepare.cvs_dir + $name + source : 'softB_SRC' + tag : '' + } + git_info: + { + repo : $SITE.prepare.default_git_server + $VARS.sep + $name + repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name + tag : $APPLICATION.default_version_to_download + } + archive_info: + { + archive_name : $SITE.prepare.archive_dir + $VARS.sep + $name + '.tar.gz' + } + environ : + { + "_LD_LIBRARY_PATH" : "${SOFT_ROOT_DIR}" + $VARS.sep + "lib" + "_PYTHONPATH" : ["${SOFT_ROOT_DIR}" + $VARS.sep + "lib" + "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR0}" + "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR1}"] + } + depend : ['softA'] + opt_depend : [] + } +} \ No newline at end of file diff --git a/src/common/internal_config/distrib.pyconf b/src/common/internal_config/distrib.pyconf new file mode 100644 index 0000000..18e6edd --- /dev/null +++ b/src/common/internal_config/distrib.pyconf @@ -0,0 +1,57 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- + +# distribution codes +# Code to use to replace the value returned by: lsb_release -si +# If no code is found an error will be raised. +DISTRIBUTIONS : +{ + "bullxServer": "BS" + "CentOS": "CO" + "Debian": "DB" + "Fedora": "FD" + "LinuxMint": "MN" + "Mageia": "MG" + "MandrivaLinux": "MD" + "RedHatEnterpriseServer": "RH" + "Ubuntu": "UB" + "openSUSE project":"OS" +} + +# versions substitution +# Code to use for release, to the replace value returned by: lsb_release -sr +# If no code is found the value is used. +VERSIONS : +{ + "DB": + { + "unstable": "sid" + "5.0": "05" + "4.0": "04" + "6.0.7" : "06" + "6.0.10": "06" + "7.1" : "07" + "7.5" : "07" + } + "MD": + { + "2008.0": "08" + "2010.0": "10" + "2010.1": "10" + "2010.2": "10" + "2007.1": "07" + "2006.0": "06" + "4" : "06" + } + "MG": + { + "3": "03" + "4": "04" + "5": "05" + "6": "06" + } + "CO": + { + "7.1.1503": "7.1" + } +} diff --git a/src/config.py b/src/config.py index 32dda39..791e5db 100644 --- a/src/config.py +++ b/src/config.py @@ -98,7 +98,7 @@ class ConfigManager: var['personalDir'] = os.path.join(os.path.expanduser('~'), '.salomeTools') # read linux distributions dictionary - distrib_cfg = common.config_pyconf.Config(os.path.join(var['dataDir'], "distrib.pyconf")) + distrib_cfg = common.config_pyconf.Config(os.path.join(var['srcDir'], 'common', 'internal_config', 'distrib.pyconf')) # set platform parameters dist_name = common.architecture.get_distribution(codes=distrib_cfg.DISTRIBUTIONS) @@ -225,6 +225,7 @@ class ConfigManager: for rule in self.get_command_line_overrides(options, ["SITE"]): exec('cfg.' + rule) # this cannot be factorized because of the exec + # ======================================================================================= # Load APPLICATION config file @@ -245,6 +246,31 @@ class ConfigManager: for rule in self.get_command_line_overrides(options, ["APPLICATION"]): exec('cfg.' + rule) # this cannot be factorized because of the exec + # ======================================================================================= + # Load softwares config files in SOFTWARE section + + # The directory containing the softwares definition + softsDir = os.path.join(cfg.VARS.dataDir, 'software_pyconf') + + # Loop on all files that are in softsDir directory and read its config + for fName in os.listdir(softsDir): + if fName.endswith(".pyconf"): + common.config_pyconf.streamOpener = ConfigOpener([softsDir]) + try: + soft_cfg = common.config_pyconf.Config(open(os.path.join(softsDir, fName))) + except common.config_pyconf.ConfigError as e: + raise common.SatException(_("Error in configuration file: %(soft)s\n %(error)s") % \ + {'soft' : fName, 'error': str(e) }) + except IOError as error: + e = str(error) + raise common.SatException( e ); + + merger.merge(cfg, soft_cfg) + + for rule in self.get_command_line_overrides(options, ["SOFTWARE"]): + exec('cfg.' + rule) # this cannot be factorized because of the exec + + # ======================================================================================= # load USER config self.setUserConfigFile(cfg) @@ -487,5 +513,6 @@ def run(args, runner): sys.stdout.write("%s\n" % appliname) sys.stdout.write("\n") + \ No newline at end of file