From 0949322f6b26088071f36c24f04a0f7c66b4f5f8 Mon Sep 17 00:00:00 2001 From: crouzet Date: Mon, 25 May 2020 17:28:44 +0200 Subject: [PATCH] sat #18855 : decodage de bytes en python3 --- src/system.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/system.py b/src/system.py index 3360807..56141bc 100644 --- a/src/system.py +++ b/src/system.py @@ -69,7 +69,10 @@ def git_describe(repo_path): return False else: tag_description=p.stdout.readlines()[0].strip() - return tag_description.decode('utf-8') + # 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): @@ -377,10 +380,14 @@ def check_system_pkg(check_cmd,pkg): stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, err = p.communicate() + rc = p.returncode if rc==0: msg_status=src.printcolors.printcSuccess("OK") if check_cmd[0]=="rpm": # apt output is too messy for being used + # 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: msg_status=src.printcolors.printcError("KO") -- 2.30.2