emaint logs: simplify error output handling v2.2.0_alpha121
authorZac Medico <zmedico@gentoo.org>
Sat, 11 Aug 2012 22:52:30 +0000 (15:52 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 11 Aug 2012 22:52:30 +0000 (15:52 -0700)
pym/_emerge/main.py
pym/portage/emaint/modules/logs/logs.py

index f19994c46c7781b20d3c6b761da0c98712bf90fd..d4b2901e3e45e4d0f29647c57a867f64d2c3cbd5 100644 (file)
@@ -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
index 32c8508f70f7ecfd7c240b687afa61b039b58310..fe65cf587de934ad660c971f03daa65b80125e78 100644 (file)
@@ -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