Create a BinpkgPrefetcher composite task to handle fetch, verification,
authorZac Medico <zmedico@gentoo.org>
Fri, 12 Dec 2008 21:36:34 +0000 (21:36 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 12 Dec 2008 21:36:34 +0000 (21:36 -0000)
and injection. (trunk r12194)

svn path=/main/branches/2.1.6/; revision=12227

pym/_emerge/__init__.py

index 14dc6bb10e6aeb3849880c81d958643a8db095ee..394a34e1280d3e54a15644f23c826817540623c1 100644 (file)
@@ -3517,6 +3517,40 @@ class BinpkgVerifier(AsynchronousTask):
                self.returncode = rval
                self.wait()
 
+class BinpkgPrefetcher(CompositeTask):
+
+       __slots__ = ("pkg",) + \
+               ("pkg_path", "_bintree",)
+
+       def _start(self):
+               self._bintree = self.pkg.root_config.trees["bintree"]
+               fetcher = BinpkgFetcher(background=self.background,
+                       logfile=self.scheduler.fetch.log_file, pkg=self.pkg,
+                       scheduler=self.scheduler)
+               self.pkg_path = fetcher.pkg_path
+               self._start_task(fetcher, self._fetcher_exit)
+
+       def _fetcher_exit(self, fetcher):
+
+               if self._default_exit(fetcher) != os.EX_OK:
+                       self.wait()
+                       return
+
+               verifier = BinpkgVerifier(background=self.background,
+                       logfile=self.scheduler.fetch.log_file, pkg=self.pkg)
+               self._start_task(verifier, self._verifier_exit)
+
+       def _verifier_exit(self, verifier):
+               if self._default_exit(verifier) != os.EX_OK:
+                       self.wait()
+                       return
+
+               self._bintree.inject(self.pkg.cpv, filename=self.pkg_path)
+
+               self._current_task = None
+               self.returncode = os.EX_OK
+               self.wait()
+
 class BinpkgExtractorAsync(SpawnProcess):
 
        __slots__ = ("image_dir", "pkg", "pkg_path")
@@ -9748,9 +9782,8 @@ class Scheduler(PollScheduler):
                        "--getbinpkg" in self.myopts and \
                        pkg.root_config.trees["bintree"].isremote(pkg.cpv):
 
-                       prefetcher = BinpkgFetcher(background=True,
-                               logfile=self._fetch_log, pkg=pkg,
-                               scheduler=self._sched_iface)
+                       prefetcher = BinpkgPrefetcher(background=True,
+                               pkg=pkg, scheduler=self._sched_iface)
 
                return prefetcher