From 24bea8d054b6cbece77bca62b149416e8e61d933 Mon Sep 17 00:00:00 2001 From: Serge Rehbinder Date: Fri, 29 Jan 2016 11:44:25 +0100 Subject: [PATCH] Add software read in config --- data/site.pyconf | 8 +++++ data/software_pyconf/softA.pyconf | 36 +++++++++++++++++++ data/software_pyconf/softB.pyconf | 36 +++++++++++++++++++ .../common/internal_config}/distrib.pyconf | 0 src/config.py | 29 ++++++++++++++- 5 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 data/software_pyconf/softA.pyconf create mode 100644 data/software_pyconf/softB.pyconf rename {data => src/common/internal_config}/distrib.pyconf (100%) 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/data/distrib.pyconf b/src/common/internal_config/distrib.pyconf similarity index 100% rename from data/distrib.pyconf rename to src/common/internal_config/distrib.pyconf 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 -- 2.39.2