X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fsystem.py;h=672149d12cd50ae3986d55d9798e26b7dae6b94d;hb=c7954d2dbe563a25747441b444f55e2dcd6e9c8f;hp=8836383ab4e67dd2da2c33586e657bc2ed6b2a81;hpb=3e76f1ea07330e68d26e4d22d0396f5b8be7700c;p=tools%2Fsat.git diff --git a/src/system.py b/src/system.py index 8836383..672149d 100644 --- a/src/system.py +++ b/src/system.py @@ -68,7 +68,11 @@ def git_describe(repo_path): if p.returncode != 0: return False else: - return p.stdout.readlines()[0].strip() + tag_description=p.stdout.readlines()[0].strip() + # with python3 this utf8 bytes should be decoded + if isinstance(tag_description, bytes): + tag_description=tag_description.decode("utf-8", "ignore") + return tag_description def git_extract(from_what, tag, where, logger, environment=None): @@ -85,6 +89,7 @@ def git_extract(from_what, tag, where, logger, environment=None): DBG.write("git_extract", [from_what, tag, str(where)]) if not where.exists(): where.make() + where_git = os.path.join(str(where), ".git") if tag == "master" or tag == "HEAD": if src.architecture.is_windows(): cmd = "git clone %(remote)s %(where)s" @@ -92,12 +97,13 @@ def git_extract(from_what, tag, where, logger, environment=None): cmd = r""" set -x git clone %(remote)s %(where)s +touch -d "$(git --git-dir=%(where_git)s log -1 --format=date_format)" %(where)s """ - cmd = cmd % {'remote': from_what, 'tag': tag, 'where': str(where)} +#git --git-dir=%(where_git)s log -1 --format=date_format > %(where)s/last_commit_date.txt + cmd = cmd % {'remote': from_what, 'tag': tag, 'where': str(where), 'where_git': where_git} else: # NOTICE: this command only works with recent version of git # because --work-tree does not work with an absolute path - where_git = os.path.join(str(where), ".git") if src.architecture.is_windows(): cmd = "rmdir %(where)s && git clone %(remote)s %(where)s && git --git-dir=%(where_git)s --work-tree=%(where)s checkout %(tag)s" else: @@ -106,6 +112,7 @@ set -x rmdir %(where)s git clone %(remote)s %(where)s && \ git --git-dir=%(where_git)s --work-tree=%(where)s checkout %(tag)s +touch -d "$(git --git-dir=%(where_git)s log -1 --format=date_format)" %(where)s """ cmd = cmd % {'remote': from_what, 'tag': tag, @@ -113,6 +120,7 @@ git --git-dir=%(where_git)s --work-tree=%(where)s checkout %(tag)s 'where_git': where_git} + cmd=cmd.replace('date_format','"%ai"') logger.logTxtFile.write("\n" + cmd + "\n") logger.logTxtFile.flush() @@ -323,24 +331,32 @@ def svn_extract(user, stderr=subprocess.STDOUT) return (res == 0) -def get_pkg_check_cmd(): +def get_pkg_check_cmd(dist_name): '''Build the command to use for checking if a linux package is installed or not.''' + + if dist_name in ["CO","FD","MG","MD","CO","OS"]: # linux using rpm + linux="RH" + manager_msg_err="Error : command failed because sat was not able to find apt command" + else: + linux="DB" + manager_msg_err="Error : command failed because sat was not able to find rpm command" + # 1- search for an installed package manager (rpm on rh, apt on db) cmd_which_rpm=["which", "rpm"] cmd_which_apt=["which", "apt"] with open(os.devnull, 'w') as devnull: # 1) we search for apt (debian based systems) completed=subprocess.call(cmd_which_apt,stdout=devnull, stderr=subprocess.STDOUT) - if completed==0: + if completed==0 and linux=="DB": cmd_is_package_installed=["apt", "list", "--installed"] else: # 2) if apt not found search for rpm (redhat) completed=subprocess.call(cmd_which_rpm,stdout=devnull, stderr=subprocess.STDOUT) # only 3.8! ,capture_output=True) - if completed==0: + if completed==0 and linux=="RH": cmd_is_package_installed=["rpm", "-q"] else: - # no package manager was found - raise src.SatException("Error : command failed because sat was not able to find apt or rpm") + # no package manager was found corresponding to dist_name + raise src.SatException(manager_msg_err) return cmd_is_package_installed def check_system_pkg(check_cmd,pkg): @@ -368,15 +384,18 @@ def check_system_pkg(check_cmd,pkg): stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, err = p.communicate() + rc = p.returncode if rc==0: - check_res=src.printcolors.printcSuccess("OK") + msg_status=src.printcolors.printcSuccess("OK") if check_cmd[0]=="rpm": # apt output is too messy for being used - check_res+=" (" + output.replace('\n',' ') + ")\n" # remove output trailing \n + # in python3 output is a byte and should be decoded + if isinstance(output, bytes): + output = output.decode("utf-8", "ignore") + msg_status+=" (" + output.replace('\n',' ') + ")\n" # remove output trailing \n else: - check_res=src.printcolors.printcError("KO") - check_res+=" (package is not installed!)\n" + msg_status=src.printcolors.printcError("KO") + msg_status+=" (package is not installed!)\n" - msg_status="\n - "+pkg + " : " + check_res return msg_status