_fetch_log = "/var/log/emerge-fetch.log"
class _iface_class(SlotObject):
- __slots__ = ("dblinkEbuildPhase", "dblinkDisplayMerge", "fetch",
- "register", "schedule", "scheduleYield", "unregister")
+ __slots__ = ("dblinkEbuildPhase", "dblinkDisplayMerge",
+ "dblinkElog", "fetch", "register", "schedule",
+ "scheduleYield", "unregister")
class _fetch_iface_class(SlotObject):
__slots__ = ("log_file", "schedule")
self._sched_iface = self._iface_class(
dblinkEbuildPhase=self._dblink_ebuild_phase,
dblinkDisplayMerge=self._dblink_display_merge,
+ dblinkElog=self._dblink_elog,
fetch=fetch_iface, register=self._register,
schedule=self._schedule_wait, scheduleYield=self._schedule_yield,
unregister=self._unregister)
finally:
f.close()
+ def _dblink_elog(self, pkg_dblink, phase, func, msgs):
+
+ log_path = pkg_dblink.settings.get("PORTAGE_LOG_FILE")
+ log_file = None
+ out = sys.stdout
+ background = self._max_jobs > 1
+
+ if background and log_path is not None:
+ log_file = open(log_path, 'a')
+ out = log_file
+
+ try:
+ for msg in msgs:
+ func(msg, phase=phase, key=pkg_dblink.mycpv, out=out)
+ finally:
+ if log_file is not None:
+ log_file.close()
+
def _dblink_display_merge(self, pkg_dblink, msg, level=0, noiselevel=0):
log_path = pkg_dblink.settings.get("PORTAGE_LOG_FILE")
background = self._max_jobs > 1
abssymlink, movefile, _movefile, bsd_chflags, cpv_getkey
from portage.elog import elog_process
-from portage.elog.messages import ewarn
from portage.elog.filtering import filter_mergephases, filter_unmergephases
import os, re, sys, stat, errno, commands, copy, time, subprocess
"pkg_prerm() and pkg_postrm() removal " + \
"phases to be skipped entirely."
msg_lines.extend(wrap(msg, 72))
+
from portage.elog.messages import eerror
- for l in msg_lines:
- eerror(l, phase=ebuild_phase, key=self.mycpv)
+ if scheduler is None:
+ for l in msg_lines:
+ eerror(l, phase=ebuild_phase, key=self.mycpv)
+ else:
+ scheduler.dblinkElog(self,
+ ebuild_phase, eerror, msg_lines)
# process logs created during pre/postrm
elog_process(self.mycpv, self.settings, phasefilter=filter_unmergephases)
"""
showMessage = self._display_merge
+ scheduler = self._scheduler
srcroot = normalize_path(srcroot).rstrip(os.path.sep) + os.path.sep
destroot = normalize_path(destroot).rstrip(os.path.sep) + os.path.sep
from portage.elog.messages import eerror as _eerror
def eerror(lines):
- for l in lines:
- _eerror(l, phase="preinst", key=self.settings.mycpv)
+ if scheduler is None:
+ for l in lines:
+ _eerror(l, phase="preinst", key=self.settings.mycpv)
+ else:
+ scheduler.dblinkElog(self,
+ "preinst", _eerror, lines)
if slot != self.settings["SLOT"]:
showMessage("!!! WARNING: Expected SLOT='%s', got '%s'\n" % \
self.delete()
ensure_dirs(self.dbtmpdir)
- scheduler = self._scheduler
-
# run preinst script
if scheduler is None:
showMessage(">>> Merging %s to %s\n" % (self.mycpv, destroot))
from portage.util import writemsg
import os
+import sys
def collect_ebuild_messages(path):
""" Collect elog messages generated by the bash logging function stored
return logentries
_msgbuffer = {}
-def _elog_base(level, msg, phase="other", key=None, color=None):
+def _elog_base(level, msg, phase="other", key=None, color=None, out=None):
""" Backend for the other messaging functions, should not be called
directly.
"""
if color == None:
color = "GOOD"
- print colorize(color, " * ")+msg
+
+ formatted_msg = colorize(color, " * ") + msg + "\n"
+
+ if out is None:
+ sys.stdout.write(formatted_msg)
+ else:
+ out.write(formatted_msg)
+
if key not in _msgbuffer:
_msgbuffer[key] = {}
if phase not in _msgbuffer[key]:
}
def _make_msgfunction(level, color):
- def _elog(msg, phase="other", key=None):
+ def _elog(msg, phase="other", key=None, out=None):
""" Display and log a message assigned to the given key/cpv
(or unassigned if no key is given).
"""
- _elog_base(level, msg, phase=phase, key=key, color=color)
+ _elog_base(level, msg, phase=phase, key=key, color=color, out=out)
return _elog
import sys