diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-06-03 03:16:16 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-06-03 03:16:16 -0700 |
commit | 70c2a622e33e158066233da8c5ba3300d0c8fa61 (patch) | |
tree | a4d154ed70b557cfc8c3723ccbe10e5d47a9084c | |
parent | efc19df1a18d39257fb76e7259798e041d7b8619 (diff) | |
download | portage-70c2a622e33e158066233da8c5ba3300d0c8fa61.tar.gz portage-70c2a622e33e158066233da8c5ba3300d0c8fa61.tar.bz2 portage-70c2a622e33e158066233da8c5ba3300d0c8fa61.zip |
dblink.merge: remove unused scheduler callbacks
-rw-r--r-- | pym/_emerge/Scheduler.py | 68 | ||||
-rw-r--r-- | pym/portage/dbapi/vartree.py | 69 |
2 files changed, 30 insertions, 107 deletions
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index b10439a00..bdc13aa85 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -86,8 +86,7 @@ class Scheduler(PollScheduler): _fetch_log = os.path.join(_emerge_log_dir, 'emerge-fetch.log') class _iface_class(SlotObject): - __slots__ = ("dblinkEbuildPhase", "dblinkDisplayMerge", - "dblinkElog", "dblinkEmergeLog", "fetch", + __slots__ = ("fetch", "output", "register", "schedule", "scheduleSetup", "scheduleUnpack", "scheduleYield", "unregister") @@ -220,10 +219,6 @@ class Scheduler(PollScheduler): fetch_iface = self._fetch_iface_class(log_file=self._fetch_log, schedule=self._schedule_fetch) self._sched_iface = self._iface_class( - dblinkEbuildPhase=self._dblink_ebuild_phase, - dblinkDisplayMerge=self._dblink_display_merge, - dblinkElog=self._dblink_elog, - dblinkEmergeLog=self._dblink_emerge_log, fetch=fetch_iface, output=self._task_output, register=self._register, schedule=self._schedule_wait, @@ -613,67 +608,6 @@ class Scheduler(PollScheduler): return blocker_dblinks - def _dblink_pkg(self, pkg_dblink): - cpv = pkg_dblink.mycpv - type_name = RootConfig.tree_pkg_map[pkg_dblink.treetype] - root_config = self.trees[pkg_dblink.myroot]["root_config"] - installed = type_name == "installed" - repo = pkg_dblink.settings.get("PORTAGE_REPO_NAME") - return self._pkg(cpv, type_name, root_config, - installed=installed, myrepo=repo) - - def _dblink_elog(self, pkg_dblink, phase, func, msgs): - - log_path = pkg_dblink.settings.get("PORTAGE_LOG_FILE") - out = StringIO() - - for msg in msgs: - func(msg, phase=phase, key=pkg_dblink.mycpv, out=out) - - out_str = out.getvalue() - - self._task_output(out_str, log_path=log_path) - - def _dblink_emerge_log(self, msg): - self._logger.log(msg) - - def _dblink_display_merge(self, pkg_dblink, msg, level=0, noiselevel=0): - log_path = pkg_dblink.settings.get("PORTAGE_LOG_FILE") - background = self._background - - if log_path is None: - if not (background and level < logging.WARN): - portage.util.writemsg_level(msg, - level=level, noiselevel=noiselevel) - else: - self._task_output(msg, log_path=log_path) - - def _dblink_ebuild_phase(self, - pkg_dblink, pkg_dbapi, ebuild_path, phase): - """ - Using this callback for merge phases allows the scheduler - to run while these phases execute asynchronously, and allows - the scheduler control output handling. - """ - - scheduler = self._sched_iface - settings = pkg_dblink.settings - background = self._background - log_path = settings.get("PORTAGE_LOG_FILE") - - if phase in ('die_hooks', 'success_hooks'): - ebuild_phase = MiscFunctionsProcess(background=background, - commands=[phase], phase=phase, - scheduler=scheduler, settings=settings) - else: - ebuild_phase = EbuildPhase(background=background, - phase=phase, scheduler=scheduler, - settings=settings) - ebuild_phase.start() - ebuild_phase.wait() - - return ebuild_phase.returncode - def _generate_digests(self): """ Generate digests if necessary for --digests or FEATURES=digest. diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 889cb588a..16cf48b76 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -57,6 +57,7 @@ from portage import _unicode_encode from _emerge.AsynchronousLock import AsynchronousLock from _emerge.EbuildBuildDir import EbuildBuildDir from _emerge.EbuildPhase import EbuildPhase +from _emerge.emergelog import emergelog from _emerge.PollScheduler import PollScheduler from _emerge.MiscFunctionsProcess import MiscFunctionsProcess @@ -2957,6 +2958,9 @@ class dblink(object): if str_buffer: os.write(self._pipe, _unicode_encode(''.join(str_buffer))) + def _emerge_log(self, msg): + emergelog(False, msg) + def treewalk(self, srcroot, destroot, inforoot, myebuild, cleanup=0, mydbapi=None, prev_mtimes=None, counter=None): """ @@ -3003,8 +3007,6 @@ class dblink(object): encoding=_encodings['content'], errors='strict') showMessage = self._display_merge - scheduler = self._scheduler - srcroot = normalize_path(srcroot).rstrip(os.path.sep) + os.path.sep if not os.path.isdir(srcroot): @@ -3359,12 +3361,12 @@ class dblink(object): ensure_dirs(self.dbtmpdir) # run preinst script - if scheduler is None: - showMessage(_(">>> Merging %(cpv)s to %(destroot)s\n") % {"cpv":self.mycpv, "destroot":destroot}) - a = _spawn_phase("preinst", self.settings) - else: - a = scheduler.dblinkEbuildPhase( - self, mydbapi, myebuild, "preinst") + showMessage(_(">>> Merging %(cpv)s to %(destroot)s\n") % \ + {"cpv":self.mycpv, "destroot":destroot}) + phase = EbuildPhase(background=False, phase="preinst", + scheduler=self._scheduler, settings=self.settings) + phase.start() + a = phase.wait() # XXX: Decide how to handle failures here. if a != os.EX_OK: @@ -3459,11 +3461,7 @@ class dblink(object): match_from_list(PORTAGE_PACKAGE_ATOM, [self.mycpv]): reinstall_self = True - if scheduler is None: - def emerge_log(msg): - pass - else: - emerge_log = scheduler.dblinkEmergeLog + emerge_log = self._emerge_log # If we have any preserved libraries then autoclean # is forced so that preserve-libs logic doesn't have @@ -3608,13 +3606,12 @@ class dblink(object): os.path.join(self.dbpkgdir, "environment.bz2") self.settings.backup_changes("PORTAGE_UPDATE_ENV") try: - if scheduler is None: - a = _spawn_phase("postinst", self.settings) - if a == os.EX_OK: - showMessage(_(">>> %s merged.\n") % self.mycpv) - else: - a = scheduler.dblinkEbuildPhase( - self, mydbapi, myebuild, "postinst") + phase = EbuildPhase(background=False, phase="postinst", + scheduler=self._scheduler, settings=self.settings) + phase.start() + a = phase.wait() + if a == os.EX_OK: + showMessage(_(">>> %s merged.\n") % self.mycpv) finally: self.settings.pop("PORTAGE_UPDATE_ENV", None) @@ -4068,6 +4065,8 @@ class dblink(object): if not parallel_install: self.lockdb() self.vartree.dbapi._bump_mtime(self.mycpv) + if self._scheduler is None: + self._scheduler = PollScheduler().sched_iface try: retval = self.treewalk(mergeroot, myroot, inforoot, myebuild, cleanup=cleanup, mydbapi=mydbapi, prev_mtimes=prev_mtimes, @@ -4075,8 +4074,7 @@ class dblink(object): # If PORTAGE_BUILDDIR doesn't exist, then it probably means # fail-clean is enabled, and the success/die hooks have - # already been called by _emerge.EbuildPhase (via - # self._scheduler.dblinkEbuildPhase) prior to cleaning. + # already been called by EbuildPhase. if os.path.isdir(self.settings['PORTAGE_BUILDDIR']): if retval == os.EX_OK: @@ -4084,18 +4082,11 @@ class dblink(object): else: phase = 'die_hooks' - if self._scheduler is None: - ebuild_phase = MiscFunctionsProcess( - background=False, - commands=[phase], - scheduler=PollScheduler().sched_iface, - settings=self.settings) - ebuild_phase.start() - ebuild_phase.wait() - else: - self._scheduler.dblinkEbuildPhase( - self, mydbapi, myebuild, phase) - + ebuild_phase = MiscFunctionsProcess( + background=False, commands=[phase], + scheduler=self._scheduler, settings=self.settings) + ebuild_phase.start() + ebuild_phase.wait() self._elog_process() if 'noclean' not in self.settings.features and \ @@ -4106,12 +4097,10 @@ class dblink(object): doebuild_environment(myebuild, "clean", settings=self.settings, db=mydbapi) - if self._scheduler is None: - _spawn_phase("clean", self.settings) - else: - self._scheduler.dblinkEbuildPhase( - self, mydbapi, myebuild, "clean") - + phase = EbuildPhase(background=False, phase="clean", + scheduler=self._scheduler, settings=self.settings) + phase.start() + phase.wait() finally: self.settings.pop('REPLACING_VERSIONS', None) if self.vartree.dbapi._linkmap is None: |