Eliminate redundant code in Scheduler._run_pkg_pretend() and remove unused
authorZac Medico <zmedico@gentoo.org>
Wed, 7 Apr 2010 20:17:58 +0000 (13:17 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 7 Apr 2010 20:17:58 +0000 (13:17 -0700)
quiet_config variables.

pym/_emerge/Scheduler.py

index f7c644ec0ef872fc7604c35e4e665f6cf16c343a..b80fa900715a277d9137954bd70b148a120a60bb 100644 (file)
@@ -857,13 +857,6 @@ class Scheduler(PollScheduler):
 
        def _run_pkg_pretend(self):
                shown_verifying_msg = False
-               quiet_settings = {}
-               for myroot, pkgsettings in self.pkgsettings.items():
-                       quiet_config = portage.config(clone=pkgsettings)
-                       quiet_config["PORTAGE_QUIET"] = "1"
-                       quiet_config.backup_changes("PORTAGE_QUIET")
-                       quiet_settings[myroot] = quiet_config
-                       del quiet_config
 
                failures = 0
 
@@ -889,10 +882,13 @@ class Scheduler(PollScheduler):
                                portage.util.writemsg_stdout(out_str, noiselevel=-1)
 
                        root_config = x.root_config
-                       quiet_config = quiet_settings[root_config.root]
                        settings = self.pkgsettings[root_config.root]
+                       tmpdir = tempfile.mkdtemp()
+                       tmpdir_orig = settings["PORTAGE_TMPDIR"]
+                       settings["PORTAGE_TMPDIR"] = tmpdir
 
                        if x.built:
+                               tree = "bintree"
                                bintree = root_config.trees["bintree"].dbapi.bintree
                                if bintree.isremote(x.cpv):
                                        fetcher = BinpkgPrefetcher(background=self._background,
@@ -903,57 +899,36 @@ class Scheduler(PollScheduler):
                                tbz2_file = bintree.getname(x.cpv)
                                ebuild_file_name = x.cpv.split("/")[1] + ".ebuild"
                                ebuild_file_contents = portage.xpak.tbz2(tbz2_file).getfile(ebuild_file_name)
-                               tmpdir = tempfile.mkdtemp()
                                os.makedirs(os.path.join(tmpdir, x.category, x.pf))
                                ebuild_path = os.path.join(tmpdir, x.category, x.pf, ebuild_file_name)
                                file = open(ebuild_path, 'w')
                                file.write(ebuild_file_contents)
                                file.close()
-                               quiet_config["O"] = os.path.dirname(ebuild_path)
-                               tmpdir_orig = settings["PORTAGE_TMPDIR"]
-                               settings["PORTAGE_TMPDIR"] = tmpdir
-
-                               portage.package.ebuild.doebuild.doebuild_environment(ebuild_path, "pretend",
-                                       root_config.root, settings, debug=(settings.get("PORTAGE_DEBUG", "") == 1),
-                                       mydbapi=self.trees[settings["ROOT"]]["bintree"].dbapi, use_cache=1)
-                               prepare_build_dirs(root_config.root, settings, cleanup=0)
-                               pretend_phase = EbuildPhase(background=self._background, pkg=x, phase="pretend",
-                                       scheduler=self._sched_iface, settings=settings, tree="bintree")
 
-                               pretend_phase.start()
-                               ret = pretend_phase.wait()
-
-                               portage.elog.elog_process(x.cpv, settings)
-
-                               if ret == os.EX_OK:
-                                       shutil.rmtree(tmpdir)
-                               settings["PORTAGE_TMPDIR"] = tmpdir_orig
                        else:
+                               tree = "porttree"
                                portdb = root_config.trees["porttree"].dbapi
                                ebuild_path = portdb.findname(x.cpv)
                                if ebuild_path is None:
                                        raise AssertionError("ebuild not found for '%s'" % x.cpv)
-                               quiet_config["O"] = os.path.dirname(ebuild_path)
-
-                               tmpdir = tempfile.mkdtemp()
-                               tmpdir_orig = settings["PORTAGE_TMPDIR"]
-                               settings["PORTAGE_TMPDIR"] = tmpdir
 
-                               portage.package.ebuild.doebuild.doebuild_environment(ebuild_path, "pretend",
-                                       root_config.root, settings, debug=(settings.get("PORTAGE_DEBUG", "") == 1),
-                                       mydbapi=self.trees[settings["ROOT"]]["porttree"].dbapi, use_cache=1)
-                               prepare_build_dirs(root_config.root, settings, cleanup=0)
-                               pretend_phase = EbuildPhase(background=self._background, pkg=x, phase="pretend",
-                                       scheduler=self._sched_iface, settings=settings, tree="porttree")
+                       portage.package.ebuild.doebuild.doebuild_environment(ebuild_path,
+                               "pretend", root_config.root, settings,
+                               debug=(settings.get("PORTAGE_DEBUG", "") == 1),
+                               mydbapi=self.trees[settings["ROOT"]][tree].dbapi, use_cache=1)
+                       prepare_build_dirs(root_config.root, settings, cleanup=0)
+                       pretend_phase = EbuildPhase(background=self._background, pkg=x,
+                               phase="pretend", scheduler=self._sched_iface,
+                               settings=settings, tree=tree)
 
-                               pretend_phase.start()
-                               ret = pretend_phase.wait()
+                       pretend_phase.start()
+                       ret = pretend_phase.wait()
 
-                               portage.elog.elog_process(x.cpv, settings)
+                       portage.elog.elog_process(x.cpv, settings)
 
-                               if ret == os.EX_OK:
-                                       shutil.rmtree(tmpdir)
-                               settings["PORTAGE_TMPDIR"] = tmpdir_orig
+                       if ret == os.EX_OK:
+                               shutil.rmtree(tmpdir)
+                       settings["PORTAGE_TMPDIR"] = tmpdir_orig
 
                        if ret != os.EX_OK:
                                failures += 1