Redirect dblink.unmerge() output to the log file when --jobs > 1.
authorZac Medico <zmedico@gentoo.org>
Wed, 16 Jul 2008 00:44:58 +0000 (00:44 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 16 Jul 2008 00:44:58 +0000 (00:44 -0000)
svn path=/main/trunk/; revision=11065

pym/_emerge/__init__.py
pym/portage/dbapi/vartree.py

index 8e5c64ecac7f16f30ec93b02eda766370b258386..9046dd26576b4a5cc96f86d07d1fe529d02eb470 100644 (file)
@@ -8320,7 +8320,7 @@ class Scheduler(PollScheduler):
        _fetch_log = "/var/log/emerge-fetch.log"
 
        class _iface_class(SlotObject):
-               __slots__ = ("dblinkEbuildPhase", "fetch",
+               __slots__ = ("dblinkEbuildPhase", "dblinkDisplayUnmerge", "fetch",
                        "register", "schedule", "unregister")
 
        class _fetch_iface_class(SlotObject):
@@ -8385,6 +8385,7 @@ class Scheduler(PollScheduler):
                        schedule=self._schedule_fetch)
                self._sched_iface = self._iface_class(
                        dblinkEbuildPhase=self._dblink_ebuild_phase,
+                       dblinkDisplayUnmerge=self._dblink_display_unmerge,
                        fetch=fetch_iface, register=self._register,
                        schedule=self._schedule_wait, unregister=self._unregister)
 
@@ -8574,6 +8575,16 @@ class Scheduler(PollScheduler):
                finally:
                        f.close()
 
+       def _dblink_display_unmerge(self, settings, msg, noiselevel=0):
+               log_path = settings.get("PORTAGE_LOG_FILE")
+               background = self._max_jobs > 1
+               if log_path is None:
+                       portage.writemsg_stdout(msg, noiselevel=noiselevel)
+               else:
+                       if not background:
+                               portage.writemsg_stdout(msg, noiselevel=noiselevel)
+                       self._append_to_log_path(log_path, msg)
+
        def _dblink_ebuild_phase(self,
                pkg_dblink, pkg_dbapi, ebuild_path, phase):
                """
index c189dce21fe539adb92ed45091a4f002a530f71a..8eb640007daebca5145e4cb983f90864fe712ef3 100644 (file)
@@ -1751,8 +1751,16 @@ class dblink(object):
                @rtype: None
                """
 
+               if self._scheduler is None:
+                       def showMessage(msg, noiselevel=0):
+                               writemsg_stdout(msg, noiselevel=noiselevel)
+               else:
+                       def showMessage(msg, noiselevel=0):
+                               self._scheduler.dblinkDisplayUnmerge(
+                                       self.settings, msg, noiselevel=noiselevel)
+
                if not pkgfiles:
-                       writemsg_stdout("No package files given... Grabbing a set.\n")
+                       showMessage("No package files given... Grabbing a set.\n")
                        pkgfiles = self.getcontents()
 
                if others_in_slot is None:
@@ -1816,7 +1824,7 @@ class dblink(object):
                                                bsd_chflags.chflags(parent_name, pflags)
 
                        def show_unmerge(zing, desc, file_type, file_name):
-                                       writemsg_stdout("%s %s %s %s\n" % \
+                                       showMessage("%s %s %s %s\n" % \
                                                (zing, desc.ljust(8), file_type, file_name))
                        for objkey in mykeys:
                                obj = normalize_path(objkey)