Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10936 - main/trunk/pym/_emerge
Date: Sat, 05 Jul 2008 07:34:32
Message-Id: E1KF2Hq-00082y-CD@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-07-05 07:34:25 +0000 (Sat, 05 Jul 2008)
3 New Revision: 10936
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 Log:
8 Rename BinpkgFetcherAsync class to BinpkgFetcher and use it to replace the
9 older class with the same name
10
11
12 Modified: main/trunk/pym/_emerge/__init__.py
13 ===================================================================
14 --- main/trunk/pym/_emerge/__init__.py 2008-07-05 07:18:31 UTC (rev 10935)
15 +++ main/trunk/pym/_emerge/__init__.py 2008-07-05 07:34:25 UTC (rev 10936)
16 @@ -2194,6 +2194,8 @@
17 settings = self.settings
18 world_atom = self.world_atom
19 tree = "bintree"
20 + root_config = pkg.root_config
21 + bintree = root_config.trees[tree]
22 settings.setcpv(pkg)
23 debug = settings.get("PORTAGE_DEBUG") == "1"
24 verify = "strict" in settings.features and \
25 @@ -2231,19 +2233,21 @@
26 retval = prefetcher.wait()
27 del prefetcher
28
29 - fetcher = BinpkgFetcher(pkg=pkg, pretend=opts.pretend,
30 - use_locks=("distlocks" in settings.features))
31 + fetcher = BinpkgFetcher(pkg=pkg, scheduler=scheduler)
32 pkg_path = fetcher.pkg_path
33
34 - if opts.getbinpkg:
35 - retval = fetcher.execute()
36 - if fetcher.remote:
37 - msg = " --- (%s of %s) Fetching Binary (%s::%s)" %\
38 - (pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg_path)
39 - short_msg = "emerge: (%s of %s) %s Fetch" % \
40 - (pkg_count.curval, pkg_count.maxval, pkg.cpv)
41 - logger.log(msg, short_msg=short_msg)
42 + if opts.getbinpkg and bintree.isremote(pkg.cpv):
43
44 + msg = " --- (%s of %s) Fetching Binary (%s::%s)" %\
45 + (pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg_path)
46 + short_msg = "emerge: (%s of %s) %s Fetch" % \
47 + (pkg_count.curval, pkg_count.maxval, pkg.cpv)
48 + logger.log(msg, short_msg=short_msg)
49 +
50 + fetcher.start()
51 + scheduler.schedule(fetcher.reg_id)
52 + retval = fetcher.wait()
53 +
54 if retval != os.EX_OK:
55 return retval
56
57 @@ -2380,66 +2384,8 @@
58 self.unlock()
59 return os.EX_OK
60
61 -class BinpkgFetcher(Task):
62 +class BinpkgFetcher(SpawnProcess):
63
64 - __slots__ = ("use_locks", "pkg", "pretend", "pkg_path", "remote")
65 -
66 - def __init__(self, **kwargs):
67 - Task.__init__(self, **kwargs)
68 - pkg = self.pkg
69 - self.pkg_path = pkg.root_config.trees["bintree"].getname(pkg.cpv)
70 -
71 - def _get_hash_key(self):
72 - hash_key = getattr(self, "_hash_key", None)
73 - if hash_key is None:
74 - self._hash_key = ("BinpkgFetcher", self.pkg._get_hash_key())
75 - return self._hash_key
76 -
77 - def execute(self):
78 - tbz2_lock = None
79 - use_locks = self.use_locks
80 - pkg = self.pkg
81 - pretend = self.pretend
82 - bintree = pkg.root_config.trees["bintree"]
83 - pkgdir = bintree.pkgdir
84 - pkg_path = self.pkg_path
85 - rval = os.EX_OK
86 -
87 - try:
88 - try:
89 - if not pretend and use_locks and os.access(pkgdir, os.W_OK):
90 - portage.util.ensure_dirs(os.path.dirname(pkg_path))
91 - tbz2_lock = portage.locks.lockfile(pkg_path,
92 - wantnewlockfile=1)
93 - if bintree.isremote(pkg.cpv):
94 - self.remote = True
95 - if not pretend:
96 - bintree.gettbz2(pkg.cpv)
97 - finally:
98 - if tbz2_lock is not None:
99 - portage.locks.unlockfile(tbz2_lock)
100 - except portage.exception.FileNotFound:
101 - writemsg("!!! Fetching Binary failed " + \
102 - "for '%s'\n" % pkg.cpv, noiselevel=-1)
103 - rval = 1
104 - except portage.exception.DigestException, e:
105 - writemsg("\n!!! Digest verification failed:\n",
106 - noiselevel=-1)
107 - writemsg("!!! %s\n" % e.value[0],
108 - noiselevel=-1)
109 - writemsg("!!! Reason: %s\n" % e.value[1],
110 - noiselevel=-1)
111 - writemsg("!!! Got: %s\n" % e.value[2],
112 - noiselevel=-1)
113 - writemsg("!!! Expected: %s\n" % e.value[3],
114 - noiselevel=-1)
115 - if not pretend:
116 - os.unlink(pkg_path)
117 - rval = 1
118 - return rval
119 -
120 -class BinpkgFetcherAsync(SpawnProcess):
121 -
122 __slots__ = ("pkg",
123 "locked", "pkg_path", "_lock_obj")
124
125 @@ -7448,7 +7394,7 @@
126 "--getbinpkg" in self.myopts and \
127 pkg.root_config.trees["bintree"].isremote(pkg.cpv):
128
129 - prefetcher = BinpkgFetcherAsync(logfile=self._fetch_log,
130 + prefetcher = BinpkgFetcher(logfile=self._fetch_log,
131 pkg=pkg, scheduler=self._sched_iface)
132
133 return prefetcher
134
135 --
136 gentoo-commits@l.g.o mailing list