+def get_launcher_name(config):
+ """\
+ Returns the name of salome launcher.
+
+ :param config Config: The global Config instance.
+ :return: The name of salome launcher.
+ :rtype: str
+ """
+ check_config_has_application(config)
+ if 'profile' in config.APPLICATION and 'launcher_name' in config.APPLICATION.profile:
+ launcher_name = config.APPLICATION.profile.launcher_name
+ else:
+ launcher_name = 'salome'
+
+ return launcher_name
+
+def get_log_path(config):
+ """\
+ Returns the path of the logs.
+
+ :param config Config: The global Config instance.
+ :return: The path of the logs.
+ :rtype: str
+ """
+ if "log_dir" not in config.LOCAL:
+ local_file_path = os.path.join(config.VARS.salometoolsway,
+ "data",
+ "local.pyconf")
+ msg = _("Please define a log_dir in the file %s" % local_file_path)
+ raise SatException(msg)
+
+ log_dir_path = os.path.abspath(config.LOCAL.log_dir)
+
+ return log_dir_path
+
+def get_salometool_version(config):
+ """Return the salomeTool version.
+
+ :param config Config: The global Config instance.
+ :return: the description of this version of sat in terms of tag and commit
+ """
+ # we use :
+ # config.VARS.salometoolsway : the full path of salomeTool
+ # config.INTERNAL.sat_version : the static salomeTool version,
+ # in case we are not in a git repo
+ sat_version=system.git_describe(config.VARS.salometoolsway)
+ if sat_version == False:
+ return config.INTERNAL.sat_version
+ else:
+ return sat_version
+
+def get_salome_version(config):
+ import versionMinorMajorPatch as VMMP
+
+ if hasattr(config.APPLICATION, 'version_salome'):
+ version = VMMP.MinorMajorPatch(config.APPLICATION.version_salome)
+ else:
+ kernel_info = product.get_product_config(config, "KERNEL")
+ aFile = os.path.join(
+ kernel_info.install_dir,
+ "bin",
+ "salome",
+ "VERSION")
+ if not os.path.isfile(aFile):
+ return None
+ with open(aFile) as f:
+ line = f.readline() # example: '[SALOME KERNEL] : 8.4.0'
+ version = VMMP.MinorMajorPatch(line.split(":")[1])
+
+ res = version.strCompact()
+ # print("get_salome_version %s -> %s" % (version, res))
+ return int(res) # TODO may be future avoid test(s) on integer, use MajorMinorPatch
+
+def read_config_from_a_file(filePath):
+ try:
+ cfg_file = pyconf.Config(filePath)
+ except pyconf.ConfigError as e:
+ raise SatException(_("Error in configuration file: %(file)s\n %(error)s") % \
+ { 'file': filePath, 'error': str(e) })
+ return cfg_file
+
+def get_tmp_filename(cfg, name):
+ if not os.path.exists(cfg.VARS.tmp_root):
+ os.makedirs(cfg.VARS.tmp_root)
+
+ return os.path.join(cfg.VARS.tmp_root, name)
+