From e298838949ce3b2ab924a303dff3cbeffc9b39f3 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 26 Mar 2019 19:45:16 +0100 Subject: [PATCH] Filter boring apt warnings + report an error if there was real warnings --- locales/en.json | 1 + src/yunohost/tools.py | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/locales/en.json b/locales/en.json index 694df0707..da27c7cb0 100644 --- a/locales/en.json +++ b/locales/en.json @@ -483,6 +483,7 @@ "unlimit": "No quota", "unrestore_app": "App '{app:s}' will not be restored", "update_cache_failed": "Unable to update APT cache", + "update_cache_warning": "Some errors happened while updating APT cache", "updating_apt_cache": "Fetching available upgrades for system packages…", "upgrade_complete": "Upgrade complete", "upgrading_packages": "Upgrading packages…", diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index 154ad086a..f9d86ad09 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -480,12 +480,21 @@ def tools_update(ignore_apps=False, ignore_packages=False): command = "LC_ALL=C apt update" # TODO : add @is_unit_operation to tools_update so that the # debug output can be fetched when there's an issue... + + # Filter boring message about "apt not having a stable CLI interface" + # Also keep track of wether or not we encountered a warning... + warnings = [] + def is_legit_warning(m): + legit_warning = m.rstrip() and "apt does not have a stable CLI interface" not in m.rstrip() + if legit_warning: + warnings.append(m) + return legit_warning + callbacks = ( # stdout goes to debug lambda l: logger.debug(l.rstrip()), - # stderr goes to warning - # FIXME : filter the damn "CLI interface not stable" from apt >.> - lambda l: logger.warning(l.rstrip()), + # stderr goes to warning except for the boring apt messages + lambda l: logger.warning(l.rstrip()) if is_legit_warning(l) else logger.debug(l.rstrip()) ) logger.info(m18n.n('updating_apt_cache')) @@ -499,6 +508,8 @@ def tools_update(ignore_apps=False, ignore_packages=False): # and append it to the error message to improve debugging raise YunohostError('update_cache_failed') + elif warnings: + logger.error(m18n.n('update_cache_warning')) packages = list(_list_upgradable_apt_packages()) logger.debug(m18n.n('done'))