diff options
-rw-r--r-- | pym/_emerge/__init__.py | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index cf43a9efe..fafc59f94 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -8691,6 +8691,9 @@ class Scheduler(PollScheduler): kwargs.pop("short_msg", None) emergelog(self.xterm_titles, *pargs, **kwargs) + class _failed_pkg(SlotObject): + __slots__ = ("log_path", "pkg", "returncode") + def __init__(self, settings, trees, mtimedb, myopts, spinner, mergelist, favorites, digraph): PollScheduler.__init__(self) @@ -9239,8 +9242,8 @@ class Scheduler(PollScheduler): if not failed_pkgs: break - for failed_pkg, returncode in failed_pkgs: - mergelist.remove(list(failed_pkg)) + for failed_pkg in failed_pkgs: + mergelist.remove(list(failed_pkg.pkg)) self._failed_pkgs_all.extend(failed_pkgs) del failed_pkgs[:] @@ -9260,7 +9263,7 @@ class Scheduler(PollScheduler): def _eerror(lines): for l in lines: - eerror(l, phase="other", key=failed_pkg.cpv) + eerror(l, phase="other", key=failed_pkg.pkg.cpv) msg = [] msg.append("One or more packages have been " + \ @@ -9279,8 +9282,32 @@ class Scheduler(PollScheduler): self._logger.log(" *** Finished. Cleaning up...") + if failed_pkgs: + self._failed_pkgs_all.extend(failed_pkgs) + del failed_pkgs[:] + background = self._background - if self._failed_pkgs_all and background and \ + failure_log_shown = False + if background and len(self._failed_pkgs_all) == 1: + # If only one package failed then just show it's + # whole log for easy viewing. + failed_pkg = self._failed_pkgs_all[-1] + log_path = failed_pkg.log_path + if log_path is not None: + try: + log_file = open(log_path, 'rb') + except IOError: + pass + else: + try: + for line in log_file: + writemsg_level(line, noiselevel=-1) + finally: + log_file.close() + failure_log_shown = True + + if background and not failure_log_shown and \ + self._failed_pkgs_all and \ self._failed_pkgs_die_msgs and \ not _flush_elog_mod_echo(): @@ -9312,9 +9339,9 @@ class Scheduler(PollScheduler): for line in wrap(msg, 72): writemsg("%s%s\n" % (prefix, line), noiselevel=-1) writemsg(prefix + "\n", noiselevel=-1) - for pkg, returncode in self._failed_pkgs_all: + for failed_pkg in self._failed_pkgs_all: writemsg("%s\t%s\n" % (prefix, - colorize("INFORM", str(pkg))), + colorize("INFORM", str(failed_pkg.pkg))), noiselevel=-1) writemsg(prefix + "\n", noiselevel=-1) @@ -9346,7 +9373,9 @@ class Scheduler(PollScheduler): def _do_merge_exit(self, merge): pkg = merge.merge.pkg if merge.returncode != os.EX_OK: - self._failed_pkgs.append((pkg, merge.returncode)) + log_path = merge.merge.settings.get("PORTAGE_LOG_FILE") + self._failed_pkgs.append(self._failed_pkg( + log_path=log_path, pkg=pkg, returncode=merge.returncode)) self._status_display.failed = len(self._failed_pkgs) return @@ -9381,7 +9410,9 @@ class Scheduler(PollScheduler): self._task_queues.merge.add(merge) self._status_display.merges = len(self._task_queues.merge) else: - self._failed_pkgs.append((build.pkg, build.returncode)) + log_path = build.settings.get("PORTAGE_LOG_FILE") + self._failed_pkgs.append(self._failed_pkg( + log_path=log_path, pkg=build.pkg, returncode=build.returncode)) self._status_display.failed = len(self._failed_pkgs) self._deallocate_config(build.settings) self._jobs -= 1 @@ -9410,7 +9441,7 @@ class Scheduler(PollScheduler): self._main_loop_cleanup() portage.elog._emerge_elog_listener = None if failed_pkgs: - pkg, rval = failed_pkgs[-1] + rval = failed_pkgs[-1].returncode return rval |