From 7d8a1347efcf7b6800c8a9ec765cc87c7b299fda Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 11 Aug 2012 15:52:30 -0700 Subject: [PATCH] emaint logs: simplify error output handling --- pym/_emerge/main.py | 11 +++++------ pym/portage/emaint/modules/logs/logs.py | 17 +++-------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index f19994c46..d4b2901e3 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -1356,13 +1356,12 @@ def clean_logs(settings): if logdir is None or not os.path.isdir(logdir): return - options = { - 'eerror': portage.output.EOutput().eerror, - # uncomment next line to output a succeeded message - #'einfo': portage.output.EOutput().einfo - } cleanlogs = CleanLogs() - cleanlogs.clean(settings=settings, options=options) + errors = cleanlogs.clean(settings=settings) + if errors: + out = portage.output.EOutput() + for msg in errors: + out.eerror(msg) def setconfig_fallback(root_config): setconfig = root_config.setconfig diff --git a/pym/portage/emaint/modules/logs/logs.py b/pym/portage/emaint/modules/logs/logs.py index 32c8508f7..fe65cf587 100644 --- a/pym/portage/emaint/modules/logs/logs.py +++ b/pym/portage/emaint/modules/logs/logs.py @@ -39,11 +39,10 @@ class CleanLogs(object): options: dict: 'NUM': int: number of days 'pretend': boolean - 'eerror': defaults to None, optional output module to output errors. - 'einfo': defaults to None, optional output module to output info msgs. """ messages = [] num_of_days = None + pretend = False if kwargs: # convuluted, I know, but portage.settings does not exist in # kwargs.get() when called from _emerge.main.clean_logs() @@ -54,8 +53,6 @@ class CleanLogs(object): if options: num_of_days = options.get('NUM', None) pretend = options.get('pretend', False) - eerror = options.get('eerror', None) - einfo = options.get('einfo', None) clean_cmd = settings.get("PORT_LOGDIR_CLEAN") if clean_cmd: @@ -75,7 +72,7 @@ class CleanLogs(object): if not clean_cmd: return [] rval = self._clean_logs(clean_cmd, settings) - messages += self._convert_errors(rval, eerror, einfo) + messages += self._convert_errors(rval) return messages @@ -96,19 +93,11 @@ class CleanLogs(object): @staticmethod - def _convert_errors(rval, eerror=None, einfo=None): + def _convert_errors(rval): msg = [] if rval != os.EX_OK: msg.append("PORT_LOGDIR_CLEAN command returned %s" % ("%d" % rval if rval else "None")) msg.append("See the make.conf(5) man page for " "PORT_LOGDIR_CLEAN usage instructions.") - if eerror: - for m in msg: - eerror(m) - else: - msg.append("PORT_LOGDIR_CLEAN command succeeded") - if einfo: - for m in msg: - einfo(m) return msg -- 2.26.2