diff --git a/locales/en.json b/locales/en.json index 8dac6e799..92864f348 100644 --- a/locales/en.json +++ b/locales/en.json @@ -201,6 +201,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", + "journal_does_exists": "There is not journal with the name '{journal}', use 'yunohost journal list to see all available journals'", "ldap_init_failed_to_create_admin": "LDAP initialization failed to create admin user", "ldap_initialized": "LDAP has been initialized", "license_undefined": "undefined", diff --git a/src/yunohost/journals.py b/src/yunohost/journals.py index d6a41bed5..0f1785697 100644 --- a/src/yunohost/journals.py +++ b/src/yunohost/journals.py @@ -26,9 +26,12 @@ import os import yaml +import errno from datetime import datetime +from moulinette import m18n +from moulinette.core import MoulinetteError from moulinette.utils.log import getActionLogger JOURNALS_PATH = '/var/log/yunohost/journals/' @@ -84,8 +87,8 @@ def journals_display(file_name): """ if not os.path.exists(JOURNALS_PATH): - # TODO raise exception - return {} + raise MoulinetteError(errno.EINVAL, + m18n.n('journal_does_exists', journal=file_name)) for category in os.listdir(JOURNALS_PATH): for journal in filter(lambda x: x.endswith(".journal"), os.listdir(os.path.join(JOURNALS_PATH, category))): @@ -112,8 +115,8 @@ def journals_display(file_name): "logs": logs, } - # TODO raise exception - return {} + raise MoulinetteError(errno.EINVAL, + m18n.n('journal_does_exists', journal=file_name)) class Journal(object):