tf-a-builder: log-splitter.py error handling
Occasionally, log-splitter fails due to the yaml format log file
contaminated by some unexpected characters.[1]
This patch will handle the exception and preserve the log file for
future investigation.
[1]: https://pastebin.linaro.org/view/3d884553
Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: Id686f26eed732a85ae6bb656eb7c5f0b457ef060
diff --git a/tf-a-builder/log-splitter.py b/tf-a-builder/log-splitter.py
index d47c17b..5a9c90f 100755
--- a/tf-a-builder/log-splitter.py
+++ b/tf-a-builder/log-splitter.py
@@ -49,7 +49,20 @@
raise SystemExit("The file '{}' is not exist!!".format(plain_log))
with open(plain_log, "r") as job_log:
- log_list = yaml.load(job_log, Loader=yaml.SafeLoader)
+ try:
+ log_list = yaml.load(job_log, Loader=yaml.SafeLoader)
+ except yaml.YAMLError as exc:
+ print ("Error while parsing YAML file:")
+ if hasattr(exc, 'problem_mark'):
+ if exc.context != None:
+ print (' parser says\n' + str(exc.problem_mark) + '\n ' +
+ str(exc.problem) + ' ' + str(exc.context))
+ else:
+ print (' parser says\n' + str(exc.problem_mark) + '\n ' +
+ str(exc.problem))
+ else:
+ print ("Something went wrong while parsing yaml file")
+ sys.exit(1)
try:
full_test_log = "{}/{}".format(des_dir, separated_log_file["all"])
opened_logfile["all"] = open(full_test_log, "w")