From 008c2886aa7b1aeba71918e13ef1089dd2d178c8 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Mon, 15 Jul 2019 13:30:22 +0200 Subject: [PATCH] [fix] Use read_yaml instead of custom yaml load --- src/yunohost/log.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/yunohost/log.py b/src/yunohost/log.py index 62775d619..c9314eca8 100644 --- a/src/yunohost/log.py +++ b/src/yunohost/log.py @@ -35,7 +35,7 @@ from logging import FileHandler, getLogger, Formatter from moulinette import m18n, msettings from yunohost.utils.error import YunohostError from moulinette.utils.log import getActionLogger -from moulinette.utils.filesystem import read_file +from moulinette.utils.filesystem import read_file, read_yaml CATEGORIES_PATH = '/var/log/yunohost/categories/' OPERATIONS_PATH = '/var/log/yunohost/categories/operation/' @@ -102,13 +102,8 @@ def log_list(category=[], limit=None, with_details=False): entry["started_at"] = log_datetime if with_details: - with open(md_path, "r") as md_file: - try: - metadata = yaml.safe_load(md_file) - except yaml.YAMLError: - logger.warning(m18n.n('log_corrupted_md_file', md_file=md_path)) - - entry["success"] = metadata.get("success", "?") if metadata else "?" + metadata = read_yaml(md_path) + entry["success"] = metadata.get("success", "?") if metadata else "?" result[category].append(entry)