X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2F__init__.py;h=ca569a05d6a89c5f85857af4e7e7a1dfbab07376;hb=d828b7da029994130b3717855155e49d58ee87ea;hp=2a4a7420b9bc057174b0812b0205594caf432ff2;hpb=9e0e887f4e964e4b723ab0ad457681f8c8177c78;p=tools%2Fsat.git diff --git a/src/__init__.py b/src/__init__.py index 2a4a742..ca569a0 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -26,6 +26,7 @@ import shutil import errno import stat import fnmatch +import pprint as PP from ftplib import FTP from . import pyconf @@ -110,6 +111,24 @@ def get_cfg_param(config, param_name, default): return config[param_name] return default +def strSplitN(aList, nb, skip="\n "): + """ + example + aStr = 'this-is-a-string' + splitN(aStr, 2, '-') + split it by every 2nd '-' rather than every '-' + """ + strValue = "" + i = 0 + for v in aList: + strValue += "%15s, " % str(v) + i += 1 + if i >= nb: + strValue += skip + i = 0 + if len(aList) > nb: + strValue = skip + strValue + return strValue def getProductNames(cfg, wildcards, logger): """get products names using * or ? as wildcards like shell Linux""" @@ -118,16 +137,25 @@ def getProductNames(cfg, wildcards, logger): wilds = wildcards else: wilds = [wildcards] + notFound = {} products = cfg.APPLICATION.products.keys() - for prod in products: - for wild in wildcards: + for wild in wildcards: + ok = False + for prod in products: filtered = fnmatch.filter([prod], wild) # print("filtered", prod, wild, filtered) if len(filtered) > 0: res.append(prod) - break + ok = True + continue + if not ok: + notFound[wild] = None if len(res) == 0: logger.warning("Empty list of products, from %s" % wilds) + if len(notFound.keys()) > 0: + strProd = strSplitN( sorted(products), 5) + logger.warning("products not found: %s\n availables products are:\n%s" % \ + (sorted(notFound.keys()), strProd) ) return res @@ -200,6 +228,22 @@ def get_log_path(config): 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 @@ -390,8 +434,21 @@ def find_file_in_ftppath(file_name, ftppath, installation_dir, logger): :param logger Logger: The logging instance to use for the prints. :rtype: str """ + + # make sure installation_dir exists + if not os.path.exists(installation_dir): + os.makedirs(installation_dir) + destination=os.path.join(installation_dir, file_name) - for ftp_archive in ftppath: + + # paths in ftppath may contain several paths separated by ":" + # we plit them, and push all paths in bigftppath + bigftppath=[] + for ipath in ftppath: + splpath=ipath.split(":") + bigftppath+=splpath + + for ftp_archive in bigftppath: try: # ftp_archive has the form ftp.xxx.yyy/dir1/dir2/... ftp_archive_split=ftp_archive.split("/")