d = dict()
d['user'] = config.VARS.user
d['date'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
- d['version'] = config.INTERNAL.sat_version
+ d['version'] = src.get_salometool_version(config)
d['dist'] = config.VARS.dist
f.write(readme_header_tpl.substitute(d)) # write the general header (common)
archive_name += ("PROJECT-" + project_name)
if options.sat:
- archive_name += ("salomeTools_" + runner.cfg.INTERNAL.sat_version)
+ archive_name += ("salomeTools_" + src.get_salometool_version(runner.cfg))
if len(archive_name)==0: # no option worked
msg = _("Error: Cannot name the archive\n"
" check if at least one of the following options was "
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
self.config.VARS.command})
# version of salomeTools
self.xmlFile.append_node_attrib("Site", attrib={"satversion" :
- self.config.INTERNAL.sat_version})
+ src.get_salometool_version(self.config)})
# machine name on which the command has been launched
self.xmlFile.append_node_attrib("Site", attrib={"hostname" :
self.config.VARS.hostname})
cfgManager = CONFIG.ConfigManager()
cfg = cfgManager.get_config()
# print the key corresponding to salomeTools version
- msg = (src.printcolors.printcHeader( _("Version: ") ) + cfg.INTERNAL.sat_version)
+ msg = (src.printcolors.printcHeader( _("Version: ") ) + src.get_salometool_version(cfg))
return msg
logger.write(printcolors.printcError(_("Unable to edit file %s\n")
% filePath), 1)
+def git_describe(repo_path):
+ '''Use git describe --tags command to return tag description of the git repository"
+ :param repo_path str: The git repository to describe
+ '''
+ git_cmd="cd %s;git describe --tags" % repo_path
+ p = subprocess.Popen(git_cmd, shell=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ p.wait()
+ if p.returncode != 0:
+ return False
+ else:
+ return p.stdout.readlines()[0].strip()
+
def git_extract(from_what, tag, where, logger, environment=None):
'''Extracts sources from a git repository.