[fix] Manage yaml corrupted error

This commit is contained in:
ljf 2018-05-22 21:18:59 +02:00
parent 440e96b495
commit 24bd5f9c83
2 changed files with 7 additions and 2 deletions

View file

@ -205,6 +205,7 @@
"invalid_url_format": "Invalid URL format",
"ip6tables_unavailable": "You cannot play with ip6tables here. You are either in a container or your kernel does not support it",
"iptables_unavailable": "You cannot play with iptables here. You are either in a container or your kernel does not support it",
"log_corrupted_md_file": "The yaml metadata file associated with logs is corrupted : '{md_file}'",
"log_does_exists": "There is not operation log with the name '{log}', use 'yunohost log list to see all available operation logs'",
"log_operation_unit_unclosed_properly": "Operation unit has not been closed properly",
"log_app_removelist": "Remove an application list",

View file

@ -123,8 +123,12 @@ def log_display(file_name, number=50):
infos['metadata'] = metadata
if 'log_path' in metadata:
log_path = metadata['log_path']
except yaml.YAMLError as exc:
print(exc)
except yaml.YAMLError:
error = m18n.n('log_corrupted_md_file', file=md_path)
if os.path.exists(log_path):
logger.warning(error)
else:
raise MoulinetteError(errno.EINVAL, error)
if os.path.exists(log_path):
from yunohost.service import _tail