Convert EbuildFetcher to an asynchronous interface:
authorZac Medico <zmedico@gentoo.org>
Fri, 4 Jul 2008 22:19:18 +0000 (22:19 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 4 Jul 2008 22:19:18 +0000 (22:19 -0000)
* Rename EbuildFetcher to EbuildFetchPretend.
* Rename EbuildFetcherAsync to EbuildFetcher.

svn path=/main/trunk/; revision=10932

pym/_emerge/__init__.py

index 1b73d57b925665d933c5808b7451e15875abbaf8..882b4af35feb27029d7fbebbc021ed693f077743 100644 (file)
@@ -1439,9 +1439,9 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase):
                                v = 0
                self._pkg.mtime = v
 
-class EbuildFetcher(SlotObject):
+class EbuildFetchPretend(SlotObject):
 
-       __slots__ = ("cancelled", "fetch_all", "pkg", "pretend", "settings")
+       __slots__ = ("fetch_all", "pkg", "settings")
 
        def execute(self):
                portdb = self.pkg.root_config.trees["porttree"].dbapi
@@ -1450,7 +1450,7 @@ class EbuildFetcher(SlotObject):
 
                retval = portage.doebuild(ebuild_path, "fetch",
                        self.settings["ROOT"], self.settings, debug=debug,
-                       listonly=self.pretend, fetchonly=1, fetchall=self.fetch_all,
+                       listonly=1, fetchonly=1, fetchall=self.fetch_all,
                        mydbapi=portdb, tree="porttree")
                return retval
 
@@ -1596,7 +1596,7 @@ class SpawnProcess(SubProcess):
                        self.registered = False
                return self.registered
 
-class EbuildFetcherAsync(SpawnProcess):
+class EbuildFetcher(SpawnProcess):
 
        __slots__ = ("pkg",)
 
@@ -1737,9 +1737,21 @@ class EbuildBuild(SlotObject):
                                not opts.buildpkg
 
                if opts.fetchonly:
-                       fetcher = EbuildFetcher(fetch_all=opts.fetch_all_uri,
-                               pkg=pkg, pretend=opts.pretend, settings=settings)
-                       retval = fetcher.execute()
+                       if opts.pretend:
+
+                               fetcher = EbuildFetchPretend(
+                                       fetch_all=opts.fetch_all_uri,
+                                       pkg=pkg, settings=settings)
+
+                               retval = fetcher.execute()
+
+                       else:
+
+                               fetcher = EbuildFetcher(pkg=pkg, scheduler=scheduler)
+                               fetcher.start()
+                               scheduler.schedule(fetcher.reg_id)
+                               retval = fetcher.wait()
+
                        if retval != os.EX_OK:
                                from portage.elog.messages import eerror
                                eerror("!!! Fetch for %s failed, continuing..." % pkg.cpv,
@@ -7360,7 +7372,7 @@ class Scheduler(object):
 
                elif pkg.type_name == "ebuild":
 
-                       prefetcher = EbuildFetcherAsync(logfile=self._fetch_log, pkg=pkg,
+                       prefetcher = EbuildFetcher(logfile=self._fetch_log, pkg=pkg,
                                scheduler=self._sched_iface)
 
                elif pkg.type_name == "binary" and \