Add decode ignore and debugging trace for code update
UnicodeDecodeError:
'utf-8' codec can't decode byte 0xb5 in position 1: invalid start byte
Changes:
- Add "ignore" decode directive to leave the character out of
the Unicode result
- Add debug tracing for tar image member files.
Change-Id: I1a4648d93dad1f431d68c9e416e645c5aea26c14
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/code_update_utils.py b/lib/code_update_utils.py
index 8490df0..ac1efc9 100644
--- a/lib/code_update_utils.py
+++ b/lib/code_update_utils.py
@@ -9,6 +9,7 @@
import sys
import tarfile
import time
+from robot.libraries.BuiltIn import BuiltIn
robot_pgm_dir_path = os.path.dirname(__file__) + os.sep
repo_data_path = re.sub('/lib', '/data', robot_pgm_dir_path)
@@ -151,12 +152,15 @@
version = ""
tar = tarfile.open(tar_file_path)
for member in tar.getmembers():
+ BuiltIn().log_to_console(member.name)
+ if member.name != "MANIFEST":
+ continue
f = tar.extractfile(member)
content = f.read()
if content.find(b"version=") == -1:
# This tar member does not contain the version.
continue
- content = content.decode("utf-8").split("\n")
+ content = content.decode("utf-8", "ignore").split("\n")
content = [x for x in content if "version=" in x]
version = content[0].split("=")[-1]
break