From 9d59c8555a0afcbceb42120354a1ebaf22946208 Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 4 Jun 2018 21:36:28 +0200 Subject: [PATCH] [enh] Display log help at the end of logs --- locales/en.json | 1 + src/yunohost/app.py | 9 +++++---- src/yunohost/log.py | 17 +++++++++-------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/locales/en.json b/locales/en.json index 495c95f82..0ba225e79 100644 --- a/locales/en.json +++ b/locales/en.json @@ -226,6 +226,7 @@ "log_backup_restore_system": "Restore system from a backup archive", "log_backup_restore_app": "Restore '{}' from a backup archive", "log_remove_on_failed_restore": "Remove '{}' after a failed restore from a backup archive", + "log_remove_on_failed_install": "Remove '{}' after a failed installation", "log_domain_add": "Add '{}' domain into system configuration", "log_domain_remove": "Remove '{}' domain from system configuration", "log_dyndns_subscribe": "Subscribe to a YunoHost subdomain '{}'", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 86fe1657a..570c2173d 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -788,7 +788,7 @@ def app_install(uo, auth, app, label=None, args=None, no_remove_on_failure=False logger.exception(m18n.n('unexpected_error')) finally: if install_retcode != 0: - uo.error(m18n.n('unexpected_error')) + error_msg = uo.error(m18n.n('unexpected_error')) if not no_remove_on_failure: # Setup environment for remove script env_dict_remove = {} @@ -821,9 +821,10 @@ def app_install(uo, auth, app, label=None, args=None, no_remove_on_failure=False app_ssowatconf(auth) if install_retcode == -1: - raise MoulinetteError(errno.EINTR, - m18n.g('operation_interrupted')) - raise MoulinetteError(errno.EIO, m18n.n('installation_failed')) + msg = m18n.n('operation_interrupted') + " " + error_msg + raise MoulinetteError(errno.EINTR, msg) + msg = m18n.n('installation_failed') + " " + error_msg + raise MoulinetteError(errno.EIO, msg) # Clean hooks and add new ones hook_remove(app_instance_name) diff --git a/src/yunohost/log.py b/src/yunohost/log.py index 9ced6cc22..588052058 100644 --- a/src/yunohost/log.py +++ b/src/yunohost/log.py @@ -349,7 +349,7 @@ class UnitOperation(object): """ Declare the failure of the unit operation """ - self.close(error) + return self.close(error) def close(self, error=None): """ @@ -367,18 +367,19 @@ class UnitOperation(object): desc = _get_description_from_name(self.name) if error is None: if is_api: - logger.info(m18n.n('log_link_to_log', name=self.name, desc=desc)) + msg = m18n.n('log_link_to_log', name=self.name, desc=desc) else: - logger.info(m18n.n('log_help_to_get_log', name=self.name, desc=desc)) + msg = m18n.n('log_help_to_get_log', name=self.name, desc=desc) + logger.info(msg) else: if is_api: - logger.warning("" + m18n.n('log_link_to_failed_log', - name=self.name, desc=desc) + - "") + msg = "" + m18n.n('log_link_to_failed_log', + name=self.name, desc=desc) + "" else: - logger.warning(m18n.n('log_help_to_get_failed_log', name=self.name, desc=desc)) - + msg = m18n.n('log_help_to_get_failed_log', name=self.name, desc=desc) + logger.warning(msg) self.flush() + return msg def __del__(self): """