Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10893 - in main/branches/prefix: . pym/_emerge pym/portage pym/portage/dbapi
Date: Wed, 02 Jul 2008 10:49:30
Message-Id: E1KDztr-0001ne-54@stork.gentoo.org
1 Author: grobian
2 Date: 2008-07-02 10:49:22 +0000 (Wed, 02 Jul 2008)
3 New Revision: 10893
4
5 Modified:
6 main/branches/prefix/DEVELOPING
7 main/branches/prefix/pym/_emerge/__init__.py
8 main/branches/prefix/pym/portage/__init__.py
9 main/branches/prefix/pym/portage/checksum.py
10 main/branches/prefix/pym/portage/dbapi/porttree.py
11 main/branches/prefix/pym/portage/dep.py
12 main/branches/prefix/pym/portage/getbinpkg.py
13 main/branches/prefix/pym/portage/gpg.py
14 main/branches/prefix/pym/portage/locks.py
15 Log:
16 Merged from trunk 10884:10892
17
18 | 10885 | * Rename existing EbuildBuild class to EbuildExecuter. * |
19 | zmedico | Split more code out of Scheduler._execute_task() and use it |
20 | | to make a more comprehensive EbuildBuild class. |
21
22 | 10886 | Remove debugging code from the previous commit. |
23 | zmedico | |
24
25 | 10887 | Split out a Binpkg class from code inside |
26 | zmedico | Scheduler._execute_task(). |
27
28 | 10888 | Fix inverted buildpkgonly logic. |
29 | zmedico | |
30
31 | 10889 | Fix EbuildBuild.execute() to return os.EX_OK on success. |
32 | zmedico | |
33
34 | 10890 | Py3k compatibility patch by Ali Polatel <hawking@g.o>. Don't |
35 | zmedico | use the format raise Exception, "string" |
36
37 | 10891 | Split out a SubProcess base class for EbuildFetcherAsync, |
38 | zmedico | EbuildPhase, and BinpkgFetcherAsync. |
39
40 | 10892 | Remove $PORTAGE_BUILDDIR locking from portage.pkgmerge() and |
41 | zmedico | use an instance of EbuildBuildDir instead. |
42
43
44 Modified: main/branches/prefix/DEVELOPING
45 ===================================================================
46 --- main/branches/prefix/DEVELOPING 2008-07-02 08:21:20 UTC (rev 10892)
47 +++ main/branches/prefix/DEVELOPING 2008-07-02 10:49:22 UTC (rev 10893)
48 @@ -94,6 +94,18 @@
49
50 The get call is nicer (compact) and faster (try,except are slow).
51
52 +Exceptions
53 +----------
54 +
55 +Don't use the format raise Exception, "string"
56 +It will be removed in py3k.
57 +
58 +YES:
59 + raise KeyError("No key")
60 +
61 +NO:
62 + raise KeyError, "No key"
63 +
64 Imports
65 -------
66
67
68 Modified: main/branches/prefix/pym/_emerge/__init__.py
69 ===================================================================
70 --- main/branches/prefix/pym/_emerge/__init__.py 2008-07-02 08:21:20 UTC (rev 10892)
71 +++ main/branches/prefix/pym/_emerge/__init__.py 2008-07-02 10:49:22 UTC (rev 10893)
72 @@ -66,6 +66,7 @@
73 # white looks bad on terminals with white background
74 from portage.output import bold as white
75
76 +import portage.elog
77 import portage.dep
78 portage.dep._dep_check_strict = True
79 import portage.util
80 @@ -1466,7 +1467,7 @@
81
82 class EbuildFetcher(SlotObject):
83
84 - __slots__ = ("fetch_all", "pkg", "pretend", "settings")
85 + __slots__ = ("cancelled", "fetch_all", "pkg", "pretend", "settings")
86
87 def execute(self):
88 portdb = self.pkg.root_config.trees["porttree"].dbapi
89 @@ -1479,17 +1480,63 @@
90 mydbapi=portdb, tree="porttree")
91 return retval
92
93 -class EbuildFetcherAsync(SlotObject):
94 +class SubProcess(SlotObject):
95 + __slots__ = ("cancelled", "pid", "returncode")
96
97 + def poll(self):
98 + if self.returncode is not None:
99 + return self.returncode
100 + retval = os.waitpid(self.pid, os.WNOHANG)
101 + if retval == (0, 0):
102 + return None
103 + self._set_returncode(retval)
104 + return self.returncode
105 +
106 + def cancel(self):
107 + if self.isAlive():
108 + os.kill(self.pid, signal.SIGTERM)
109 + self.cancelled = True
110 + if self.pid is not None:
111 + self.wait()
112 + return self.returncode
113 +
114 + def isAlive(self):
115 + return self.pid is not None and \
116 + self.returncode is None
117 +
118 + def wait(self):
119 + if self.returncode is not None:
120 + return self.returncode
121 + self._set_returncode(os.waitpid(self.pid, 0))
122 + return self.returncode
123 +
124 + def _set_returncode(self, wait_retval):
125 +
126 + retval = wait_retval[1]
127 + portage.process.spawned_pids.remove(self.pid)
128 + if retval != os.EX_OK:
129 + if retval & 0xff:
130 + retval = (retval & 0xff) << 8
131 + else:
132 + retval = retval >> 8
133 +
134 + self.returncode = retval
135 +
136 +class EbuildFetcherAsync(SubProcess):
137 +
138 __slots__ = ("log_file", "fd_pipes", "pkg",
139 "register", "unregister",
140 - "pid", "returncode", "files")
141 + "files")
142
143 _file_names = ("fetcher", "out")
144 _files_dict = slot_dict_class(_file_names, prefix="")
145 _bufsize = 4096
146
147 def start(self):
148 +
149 + if self.cancelled:
150 + return
151 +
152 # flush any pending output
153 fd_pipes = self.fd_pipes
154 if fd_pipes is None:
155 @@ -1572,33 +1619,6 @@
156 for f in files.values():
157 f.close()
158
159 - def poll(self):
160 - if self.returncode is not None:
161 - return self.returncode
162 - retval = os.waitpid(self.pid, os.WNOHANG)
163 - if retval == (0, 0):
164 - return None
165 - self._set_returncode(retval)
166 - return self.returncode
167 -
168 - def wait(self):
169 - if self.returncode is not None:
170 - return self.returncode
171 - self._set_returncode(os.waitpid(self.pid, 0))
172 - return self.returncode
173 -
174 - def _set_returncode(self, wait_retval):
175 -
176 - retval = wait_retval[1]
177 - portage.process.spawned_pids.remove(self.pid)
178 - if retval != os.EX_OK:
179 - if retval & 0xff:
180 - retval = (retval & 0xff) << 8
181 - else:
182 - retval = retval >> 8
183 -
184 - self.returncode = retval
185 -
186 class EbuildBuildDir(SlotObject):
187
188 __slots__ = ("pkg", "settings",
189 @@ -1671,20 +1691,138 @@
190 class AlreadyLocked(portage.exception.PortageException):
191 pass
192
193 -class EbuildBuild(Task):
194 - """
195 - TODO: Support asynchronous execution, to implement parallel builds.
196 - """
197 +class EbuildBuild(SlotObject):
198 +
199 + __slots__ = ("args_set", "find_blockers",
200 + "ldpath_mtimes", "logger", "opts",
201 + "pkg", "pkg_count", "scheduler",
202 + "settings")
203 +
204 + def execute(self):
205 +
206 + args_set = self.args_set
207 + find_blockers = self.find_blockers
208 + ldpath_mtimes = self.ldpath_mtimes
209 + logger = self.logger
210 + opts = self.opts
211 + pkg = self.pkg
212 + pkg_count = self.pkg_count
213 + scheduler = self.scheduler
214 + settings = self.settings
215 + root_config = pkg.root_config
216 + root = root_config.root
217 + system_set = root_config.sets["system"]
218 + world_set = root_config.sets["world"]
219 + vartree = root_config.trees["vartree"]
220 + portdb = root_config.trees["porttree"].dbapi
221 + debug = settings.get("PORTAGE_DEBUG") == "1"
222 + features = self.settings.features
223 + settings["EMERGE_FROM"] = pkg.type_name
224 + settings.backup_changes("EMERGE_FROM")
225 + settings.reset()
226 + ebuild_path = portdb.findname(self.pkg.cpv)
227 +
228 + #buildsyspkg: Check if we need to _force_ binary package creation
229 + issyspkg = "buildsyspkg" in features and \
230 + system_set.findAtomForPackage(pkg) and \
231 + not opts.buildpkg
232 +
233 + if opts.fetchonly:
234 + fetcher = EbuildFetcher(fetch_all=opts.fetch_all_uri,
235 + pkg=pkg, pretend=opts.pretend, settings=settings)
236 + retval = fetcher.execute()
237 + if retval != os.EX_OK:
238 + from portage.elog.messages import eerror
239 + eerror("!!! Fetch for %s failed, continuing..." % pkg.cpv,
240 + phase="unpack", key=pkg.cpv)
241 + return retval
242 +
243 + build_dir = EbuildBuildDir(pkg=pkg, settings=settings)
244 + try:
245 + build_dir.lock()
246 + # Cleaning is triggered before the setup
247 + # phase, in portage.doebuild().
248 + msg = " === (%s of %s) Cleaning (%s::%s)" % \
249 + (pkg_count.curval, pkg_count.maxval, pkg.cpv, ebuild_path)
250 + short_msg = "emerge: (%s of %s) %s Clean" % \
251 + (pkg_count.curval, pkg_count.maxval, pkg.cpv)
252 + logger.log(msg, short_msg=short_msg)
253 +
254 + if opts.buildpkg or issyspkg:
255 + if issyspkg:
256 + portage.writemsg(">>> This is a system package, " + \
257 + "let's pack a rescue tarball.\n", noiselevel=-1)
258 + msg = " === (%s of %s) Compiling/Packaging (%s::%s)" % \
259 + (pkg_count.curval, pkg_count.maxval, pkg.cpv, ebuild_path)
260 + short_msg = "emerge: (%s of %s) %s Compile" % \
261 + (pkg_count.curval, pkg_count.maxval, pkg.cpv)
262 + logger.log(msg, short_msg=short_msg)
263 +
264 + build = EbuildExecuter(pkg=pkg, register=scheduler.register,
265 + schedule=scheduler.schedule, settings=settings,
266 + unregister=scheduler.unregister)
267 + retval = build.execute()
268 + if retval != os.EX_OK:
269 + return retval
270 +
271 + build = EbuildBinpkg(pkg=pkg, settings=settings)
272 + retval = build.execute()
273 + if retval != os.EX_OK:
274 + return retval
275 +
276 + if not opts.buildpkgonly:
277 + msg = " === (%s of %s) Merging (%s::%s)" % \
278 + (pkg_count.curval, pkg_count.maxval,
279 + pkg.cpv, ebuild_path)
280 + short_msg = "emerge: (%s of %s) %s Merge" % \
281 + (pkg_count.curval, pkg_count.maxval, pkg.cpv)
282 + logger.log(msg, short_msg=short_msg)
283 +
284 + merge = EbuildMerge(
285 + find_blockers=find_blockers,
286 + ldpath_mtimes=ldpath_mtimes,
287 + pkg=pkg, settings=settings)
288 + retval = merge.execute()
289 + if retval != os.EX_OK:
290 + return retval
291 + elif "noclean" not in settings.features:
292 + portage.doebuild(ebuild_path, "clean", root,
293 + settings, debug=debug, mydbapi=portdb,
294 + tree="porttree")
295 + else:
296 + msg = " === (%s of %s) Compiling/Merging (%s::%s)" % \
297 + (pkg_count.curval, pkg_count.maxval, pkg.cpv, ebuild_path)
298 + short_msg = "emerge: (%s of %s) %s Compile" % \
299 + (pkg_count.curval, pkg_count.curval, pkg.cpv)
300 + logger.log(msg, short_msg=short_msg)
301 +
302 + build = EbuildExecuter(pkg=pkg, register=scheduler.register,
303 + schedule=scheduler.schedule, settings=settings,
304 + unregister=scheduler.unregister)
305 + retval = build.execute()
306 + if retval != os.EX_OK:
307 + return retval
308 +
309 + merge = EbuildMerge(
310 + find_blockers=self.find_blockers,
311 + ldpath_mtimes=ldpath_mtimes,
312 + pkg=pkg, settings=settings)
313 + retval = merge.execute()
314 +
315 + if retval != os.EX_OK:
316 + return retval
317 + finally:
318 + if build_dir.locked:
319 + portage.elog.elog_process(pkg.cpv, settings)
320 + build_dir.unlock()
321 + return os.EX_OK
322 +
323 +class EbuildExecuter(SlotObject):
324 +
325 __slots__ = ("pkg", "register", "schedule", "settings", "unregister")
326
327 _phases = ("setup", "unpack", "compile", "test", "install")
328
329 - def _get_hash_key(self):
330 - hash_key = getattr(self, "_hash_key", None)
331 - if hash_key is None:
332 - self._hash_key = ("EbuildBuild", self.pkg._get_hash_key())
333 - return self._hash_key
334 -
335 def execute(self):
336 root_config = self.pkg.root_config
337 portdb = root_config.trees["porttree"].dbapi
338 @@ -1730,11 +1868,11 @@
339
340 return os.EX_OK
341
342 -class EbuildPhase(SlotObject):
343 +class EbuildPhase(SubProcess):
344
345 __slots__ = ("fd_pipes", "phase", "pkg",
346 "register", "settings", "unregister",
347 - "pid", "returncode", "files")
348 + "files")
349
350 _file_names = ("log", "stdout", "ebuild")
351 _files_dict = slot_dict_class(_file_names, prefix="")
352 @@ -1835,42 +1973,17 @@
353 for f in files.values():
354 f.close()
355
356 - def poll(self):
357 - if self.returncode is not None:
358 - return self.returncode
359 - retval = os.waitpid(self.pid, os.WNOHANG)
360 - if retval == (0, 0):
361 - return None
362 - self._set_returncode(retval)
363 - return self.returncode
364 -
365 - def wait(self):
366 - if self.returncode is not None:
367 - return self.returncode
368 - self._set_returncode(os.waitpid(self.pid, 0))
369 - return self.returncode
370 -
371 def _set_returncode(self, wait_retval):
372 -
373 - retval = wait_retval[1]
374 - portage.process.spawned_pids.remove(self.pid)
375 - if retval != os.EX_OK:
376 - if retval & 0xff:
377 - retval = (retval & 0xff) << 8
378 - else:
379 - retval = retval >> 8
380 -
381 + SubProcess._set_returncode(self, wait_retval)
382 msg = portage._doebuild_exit_status_check(
383 self.phase, self.settings)
384 if msg:
385 - retval = 1
386 + self.returncode = 1
387 from textwrap import wrap
388 from portage.elog.messages import eerror
389 for l in wrap(msg, 72):
390 eerror(l, phase=self.phase, key=self.pkg.cpv)
391
392 - self.returncode = retval
393 -
394 class EbuildBinpkg(Task):
395 """
396 This assumes that src_install() has successfully completed.
397 @@ -1963,6 +2076,95 @@
398 return e.status
399 return os.EX_OK
400
401 +class Binpkg(SlotObject):
402 +
403 + __slots__ = ("find_blockers",
404 + "ldpath_mtimes", "logger", "opts",
405 + "pkg", "pkg_count", "prefetcher", "scheduler",
406 + "settings")
407 +
408 + def execute(self):
409 +
410 + find_blockers = self.find_blockers
411 + ldpath_mtimes = self.ldpath_mtimes
412 + logger = self.logger
413 + opts = self.opts
414 + pkg = self.pkg
415 + pkg_count = self.pkg_count
416 + scheduler = self.scheduler
417 + settings = self.settings
418 +
419 + # The prefetcher has already completed or it
420 + # could be running now. If it's running now,
421 + # wait for it to complete since it holds
422 + # a lock on the file being fetched. The
423 + # portage.locks functions are only designed
424 + # to work between separate processes. Since
425 + # the lock is held by the current process,
426 + # use the scheduler and fetcher methods to
427 + # synchronize with the fetcher.
428 + prefetcher = self.prefetcher
429 + if prefetcher is not None:
430 + if not prefetcher.isAlive():
431 + prefetcher.cancel()
432 + else:
433 + retval = prefetcher.poll()
434 +
435 + if retval is None:
436 + waiting_msg = ("Fetching '%s' " + \
437 + "in the background. " + \
438 + "To view fetch progress, run `tail -f " + \
439 + "/var/log/emerge-fetch.log` in another " + \
440 + "terminal.") % prefetcher.pkg_path
441 + msg_prefix = colorize("GOOD", " * ")
442 + from textwrap import wrap
443 + waiting_msg = "".join("%s%s\n" % (msg_prefix, line) \
444 + for line in wrap(waiting_msg, 65))
445 + writemsg(waiting_msg, noiselevel=-1)
446 +
447 + while retval is None:
448 + scheduler.schedule()
449 + retval = prefetcher.poll()
450 + del prefetcher
451 +
452 + fetcher = BinpkgFetcher(pkg=pkg, pretend=opts.pretend,
453 + use_locks=("distlocks" in settings.features))
454 + pkg_path = fetcher.pkg_path
455 +
456 + if opts.getbinpkg:
457 + retval = fetcher.execute()
458 + if fetcher.remote:
459 + msg = " --- (%s of %s) Fetching Binary (%s::%s)" %\
460 + (pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg_path)
461 + short_msg = "emerge: (%s of %s) %s Fetch" % \
462 + (pkg_count.curval, pkg_count.maxval, pkg.cpv)
463 + logger.log(msg, short_msg=short_msg)
464 +
465 + if retval != os.EX_OK:
466 + return retval
467 +
468 + if opts.fetchonly:
469 + return os.EX_OK
470 +
471 + msg = " === (%s of %s) Merging Binary (%s::%s)" % \
472 + (pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg_path)
473 + short_msg = "emerge: (%s of %s) %s Merge Binary" % \
474 + (pkg_count.curval, pkg_count.maxval, pkg.cpv)
475 + logger.log(msg, short_msg=short_msg)
476 +
477 + build_dir = EbuildBuildDir(pkg=pkg, settings=settings)
478 + try:
479 + build_dir.lock()
480 + merge = BinpkgMerge(find_blockers=find_blockers,
481 + ldpath_mtimes=ldpath_mtimes, pkg=pkg, pretend=opts.pretend,
482 + pkg_path=pkg_path, settings=settings)
483 + retval = merge.execute()
484 + if retval != os.EX_OK:
485 + return retval
486 + finally:
487 + build_dir.unlock()
488 + return os.EX_OK
489 +
490 class BinpkgFetcher(Task):
491
492 __slots__ = ("use_locks", "pkg", "pretend",
493 @@ -2022,25 +2224,24 @@
494 rval = 1
495 return rval
496
497 -class BinpkgFetcherAsync(SlotObject):
498 +class BinpkgFetcherAsync(SubProcess):
499
500 - __slots__ = ("cancelled", "log_file", "fd_pipes", "pkg",
501 + __slots__ = ("log_file", "fd_pipes", "pkg",
502 "register", "unregister",
503 - "locked", "files", "pid", "pkg_path", "returncode", "_lock_obj")
504 + "locked", "files", "pkg_path", "_lock_obj")
505
506 _file_names = ("fetcher", "out")
507 _files_dict = slot_dict_class(_file_names, prefix="")
508 _bufsize = 4096
509
510 def __init__(self, **kwargs):
511 - SlotObject.__init__(self, **kwargs)
512 + SubProcess.__init__(self, **kwargs)
513 pkg = self.pkg
514 self.pkg_path = pkg.root_config.trees["bintree"].getname(pkg.cpv)
515
516 def start(self):
517
518 if self.cancelled:
519 - self.pid = -1
520 return
521
522 fd_pipes = self.fd_pipes
523 @@ -2172,45 +2373,6 @@
524 self._lock_obj = None
525 self.locked = False
526
527 - def poll(self):
528 - if self.returncode is not None:
529 - return self.returncode
530 - retval = os.waitpid(self.pid, os.WNOHANG)
531 - if retval == (0, 0):
532 - return None
533 - self._set_returncode(retval)
534 - return self.returncode
535 -
536 - def cancel(self):
537 - if self.isAlive():
538 - os.kill(self.pid, signal.SIGTERM)
539 - self.cancelled = True
540 - if self.pid is not None:
541 - self.wait()
542 - return self.returncode
543 -
544 - def isAlive(self):
545 - return self.pid is not None and \
546 - self.returncode is None
547 -
548 - def wait(self):
549 - if self.returncode is not None:
550 - return self.returncode
551 - self._set_returncode(os.waitpid(self.pid, 0))
552 - return self.returncode
553 -
554 - def _set_returncode(self, wait_retval):
555 -
556 - retval = wait_retval[1]
557 - portage.process.spawned_pids.remove(self.pid)
558 - if retval != os.EX_OK:
559 - if retval & 0xff:
560 - retval = (retval & 0xff) << 8
561 - else:
562 - retval = retval >> 8
563 -
564 - self.returncode = retval
565 -
566 class BinpkgMerge(Task):
567
568 __slots__ = ("find_blockers", "ldpath_mtimes",
569 @@ -2223,6 +2385,12 @@
570 return self._hash_key
571
572 def execute(self):
573 +
574 + settings = self.settings
575 + settings["EMERGE_FROM"] = self.pkg.type_name
576 + settings.backup_changes("EMERGE_FROM")
577 + settings.reset()
578 +
579 root_config = self.pkg.root_config
580 retval = portage.pkgmerge(self.pkg_path, root_config.root,
581 self.settings,
582 @@ -6695,6 +6863,25 @@
583
584 _fetch_log = EPREFIX + "/var/log/emerge-fetch.log"
585
586 + class _iface_class(SlotObject):
587 + __slots__ = ("register", "schedule", "unregister")
588 +
589 + class _build_opts_class(SlotObject):
590 + __slots__ = ("buildpkg", "buildpkgonly",
591 + "fetch_all_uri", "fetchonly", "pretend")
592 +
593 + class _binpkg_opts_class(SlotObject):
594 + __slots__ = ("fetchonly", "getbinpkg", "pretend")
595 +
596 + class _pkg_count_class(SlotObject):
597 + __slots__ = ("curval", "maxval")
598 +
599 + class _emerge_log_class(SlotObject):
600 + __slots__ = ("xterm_titles",)
601 +
602 + def log(self, *pargs, **kwargs):
603 + emergelog(self.xterm_titles, *pargs, **kwargs)
604 +
605 def __init__(self, settings, trees, mtimedb, myopts,
606 spinner, mergelist, favorites, digraph):
607 self.settings = settings
608 @@ -6705,6 +6892,14 @@
609 self._mtimedb = mtimedb
610 self._mergelist = mergelist
611 self._favorites = favorites
612 + self._args_set = InternalPackageSet(favorites)
613 + self._build_opts = self._build_opts_class()
614 + for k in self._build_opts.__slots__:
615 + setattr(self._build_opts, k, "--" + k.replace("_", "-") in myopts)
616 + self._binpkg_opts = self._binpkg_opts_class()
617 + for k in self._binpkg_opts.__slots__:
618 + setattr(self._binpkg_opts, k, "--" + k.replace("_", "-") in myopts)
619 +
620 self.edebug = 0
621 if settings.get("PORTAGE_DEBUG", "") == "1":
622 self.edebug = 1
623 @@ -6713,6 +6908,11 @@
624 self.pkgsettings[root] = portage.config(
625 clone=trees[root]["vartree"].settings)
626 self.curval = 0
627 + self._logger = self._emerge_log_class(
628 + xterm_titles=("notitles" not in settings.features))
629 + self._sched_iface = self._iface_class(
630 + register=self._register, schedule=self._schedule,
631 + unregister=self._unregister)
632 self._poll_event_handlers = {}
633 self._poll = select.poll()
634 from collections import deque
635 @@ -6946,12 +7146,12 @@
636 "--onlydeps" in self.myopts
637 pretend = "--pretend" in self.myopts
638 ldpath_mtimes = mtimedb["ldpath"]
639 - xterm_titles = "notitles" not in self.settings.features
640 + logger = self._logger
641
642 if "--resume" in self.myopts:
643 # We're resuming.
644 print colorize("GOOD", "*** Resuming merge...")
645 - emergelog(xterm_titles, " *** Resuming merge...")
646 + self._logger.log(" *** Resuming merge...")
647
648 # Do this before verifying the ebuild Manifests since it might
649 # be possible for the user to use --resume --skipfirst get past
650 @@ -6964,6 +7164,7 @@
651 getbinpkg = "--getbinpkg" in self.myopts
652
653 if self._parallel_fetch:
654 + portage.writemsg(">>> starting parallel fetch\n")
655 for pkg in mylist:
656 if not isinstance(pkg, Package):
657 continue
658 @@ -7022,7 +7223,8 @@
659 # Filter mymergelist so that all the len(mymergelist) calls
660 # below (for display) do not count Uninstall instances.
661 mymergelist = [x for x in mymergelist if x[-1] == "merge"]
662 - mergecount=0
663 + pkg_count = self._pkg_count_class(
664 + curval=0, maxval=len(mymergelist))
665 for x in task_list:
666 if x[0] == "blocks":
667 continue
668 @@ -7046,24 +7248,24 @@
669 else:
670 raise AssertionError("Package type: '%s'" % pkg_type)
671 if not x.installed:
672 - mergecount += 1
673 + pkg_count.curval += 1
674 try:
675 self._execute_task(bad_resume_opts,
676 failed_fetches,
677 - mydbapi, mergecount,
678 + mydbapi, pkg_count,
679 myfeat, mymergelist, x,
680 - prefetchers, xterm_titles)
681 + prefetchers)
682 except self._pkg_failure, e:
683 return e.status
684 - return self._post_merge(mtimedb, xterm_titles, failed_fetches)
685 + return self._post_merge(mtimedb,
686 + self._logger.xterm_titles, failed_fetches)
687
688 def _execute_task(self, bad_resume_opts,
689 - failed_fetches, mydbapi, mergecount, myfeat,
690 - mymergelist, pkg, prefetchers, xterm_titles):
691 + failed_fetches, mydbapi, pkg_count, myfeat,
692 + mymergelist, pkg, prefetchers):
693 favorites = self._favorites
694 mtimedb = self._mtimedb
695 - from portage.elog import elog_process
696 - from portage.elog.filtering import filter_mergephases
697 + mergecount = pkg_count.curval
698 pkgsettings = self.pkgsettings[pkg.root]
699 buildpkgonly = "--buildpkgonly" in self.myopts
700 fetch_all = "--fetch-all-uri" in self.myopts
701 @@ -7076,6 +7278,7 @@
702 xterm_titles = "notitles" not in self.settings.features
703
704 x = pkg
705 + y = None
706 root_config = pkg.root_config
707 system_set = root_config.sets["system"]
708 args_set = InternalPackageSet(favorites)
709 @@ -7097,7 +7300,7 @@
710
711 if x[0]=="blocks":
712 pkgindex=3
713 - y = portdb.findname(pkg_key)
714 +
715 if "--pretend" not in self.myopts:
716 print "\n>>> Emerging (" + \
717 colorize("MERGE_LIST_PROGRESS", str(mergecount)) + " of " + \
718 @@ -7107,163 +7310,35 @@
719 str(mergecount)+" of "+str(len(mymergelist))+\
720 ") "+x[pkgindex]+" to "+x[1])
721
722 - pkgsettings["EMERGE_FROM"] = x[0]
723 - pkgsettings.backup_changes("EMERGE_FROM")
724 - pkgsettings.reset()
725 + self._schedule()
726
727 - #buildsyspkg: Check if we need to _force_ binary package creation
728 - issyspkg = ("buildsyspkg" in myfeat) \
729 - and x[0] != "blocks" \
730 - and system_set.findAtomForPackage(pkg) \
731 - and "--buildpkg" not in self.myopts
732 - if x[0] in ["ebuild","blocks"]:
733 - if x[0] == "blocks" and "--fetchonly" not in self.myopts:
734 - raise Exception, "Merging a blocker"
735 - elif fetchonly:
736 - fetcher = EbuildFetcher(fetch_all=fetch_all,
737 - pkg=pkg, pretend=pretend, settings=pkgsettings)
738 - retval = fetcher.execute()
739 - if (retval is None) or retval:
740 - print
741 - print "!!! Fetch for",y,"failed, continuing..."
742 - print
743 - failed_fetches.append(pkg_key)
744 - self.curval += 1
745 - return
746 -
747 - build_dir = EbuildBuildDir(pkg=pkg, settings=pkgsettings)
748 - try:
749 - build_dir.lock()
750 - # Cleaning is triggered before the setup
751 - # phase, in portage.doebuild().
752 - msg = " === (%s of %s) Cleaning (%s::%s)" % \
753 - (mergecount, len(mymergelist), pkg_key, y)
754 - short_msg = "emerge: (%s of %s) %s Clean" % \
755 - (mergecount, len(mymergelist), pkg_key)
756 - emergelog(xterm_titles, msg, short_msg=short_msg)
757 -
758 - if "--buildpkg" in self.myopts or issyspkg:
759 - if issyspkg:
760 - print ">>> This is a system package, " + \
761 - "let's pack a rescue tarball."
762 - msg = " === (%s of %s) Compiling/Packaging (%s::%s)" % \
763 - (mergecount, len(mymergelist), pkg_key, y)
764 - short_msg = "emerge: (%s of %s) %s Compile" % \
765 - (mergecount, len(mymergelist), pkg_key)
766 - emergelog(xterm_titles, msg, short_msg=short_msg)
767 -
768 - build = EbuildBuild(pkg=pkg, register=self._register,
769 - schedule=self._schedule, settings=pkgsettings,
770 - unregister=self._unregister)
771 - retval = build.execute()
772 - if retval != os.EX_OK:
773 - raise self._pkg_failure(retval)
774 -
775 - build = EbuildBinpkg(pkg=pkg, settings=pkgsettings)
776 - retval = build.execute()
777 - if retval != os.EX_OK:
778 - raise self._pkg_failure(retval)
779 -
780 - if "--buildpkgonly" not in self.myopts:
781 - msg = " === (%s of %s) Merging (%s::%s)" % \
782 - (mergecount, len(mymergelist), pkg_key, y)
783 - short_msg = "emerge: (%s of %s) %s Merge" % \
784 - (mergecount, len(mymergelist), pkg_key)
785 - emergelog(xterm_titles, msg, short_msg=short_msg)
786 -
787 - merge = EbuildMerge(
788 - find_blockers=self._find_blockers(pkg),
789 - ldpath_mtimes=ldpath_mtimes,
790 - pkg=pkg, pretend=pretend, settings=pkgsettings)
791 - retval = merge.execute()
792 - if retval != os.EX_OK:
793 - raise self._pkg_failure(retval)
794 - elif "noclean" not in pkgsettings.features:
795 - portage.doebuild(y, "clean", myroot,
796 - pkgsettings, self.edebug, mydbapi=portdb,
797 - tree="porttree")
798 + if x.type_name == "ebuild":
799 + y = portdb.findname(pkg.cpv)
800 + build = EbuildBuild(args_set=self._args_set,
801 + find_blockers=self._find_blockers(pkg),
802 + ldpath_mtimes=ldpath_mtimes, logger=self._logger,
803 + opts=self._build_opts, pkg=pkg, pkg_count=pkg_count,
804 + settings=pkgsettings, scheduler=self._sched_iface)
805 + retval = build.execute()
806 + if retval != os.EX_OK:
807 + if fetchonly:
808 + failed_fetches.append(pkg.cpv)
809 else:
810 - msg = " === (%s of %s) Compiling/Merging (%s::%s)" % \
811 - (mergecount, len(mymergelist), pkg_key, y)
812 - short_msg = "emerge: (%s of %s) %s Compile" % \
813 - (mergecount, len(mymergelist), pkg_key)
814 - emergelog(xterm_titles, msg, short_msg=short_msg)
815 + raise self._pkg_failure(retval)
816
817 - build = EbuildBuild(pkg=pkg, register=self._register,
818 - schedule=self._schedule, settings=pkgsettings,
819 - unregister=self._unregister)
820 - retval = build.execute()
821 - if retval != os.EX_OK:
822 - raise self._pkg_failure(retval)
823 -
824 - merge = EbuildMerge(
825 - find_blockers=self._find_blockers(pkg),
826 - ldpath_mtimes=ldpath_mtimes,
827 - pkg=pkg, pretend=pretend, settings=pkgsettings)
828 - retval = merge.execute()
829 -
830 - if retval != os.EX_OK:
831 - raise self._pkg_failure(retval)
832 - finally:
833 - if build_dir.locked:
834 - elog_process(pkg.cpv, pkgsettings,
835 - phasefilter=filter_mergephases)
836 - build_dir.unlock()
837 -
838 elif x.type_name == "binary":
839 - # The prefetcher have already completed or it
840 - # could be running now. If it's running now,
841 - # wait for it to complete since it holds
842 - # a lock on the file being fetched. The
843 - # portage.locks functions are only designed
844 - # to work between separate processes. Since
845 - # the lock is held by the current process,
846 - # use the scheduler and fetcher methods to
847 - # synchronize with the fetcher.
848 - prefetcher = prefetchers.get(pkg)
849 - if prefetcher is not None:
850 - if not prefetcher.isAlive():
851 - prefetcher.cancel()
852 + binpkg = Binpkg(find_blockers=self._find_blockers(pkg),
853 + ldpath_mtimes=ldpath_mtimes, logger=self._logger,
854 + opts=self._binpkg_opts, pkg=pkg, pkg_count=pkg_count,
855 + prefetcher=prefetchers.get(pkg), settings=pkgsettings,
856 + scheduler=self._sched_iface)
857 + retval = binpkg.execute()
858 + if retval != os.EX_OK:
859 + if fetchonly:
860 + failed_fetches.append(pkg.cpv)
861 else:
862 - retval = None
863 - while retval is None:
864 - self._schedule()
865 - retval = prefetcher.poll()
866 - del prefetcher
867 + raise self._pkg_failure(retval)
868
869 - fetcher = BinpkgFetcher(pkg=pkg, pretend=pretend,
870 - use_locks=("distlocks" in pkgsettings.features))
871 - mytbz2 = fetcher.pkg_path
872 - if "--getbinpkg" in self.myopts:
873 - retval = fetcher.execute()
874 - if fetcher.remote:
875 - msg = " --- (%s of %s) Fetching Binary (%s::%s)" %\
876 - (mergecount, len(mymergelist), pkg_key, mytbz2)
877 - short_msg = "emerge: (%s of %s) %s Fetch" % \
878 - (mergecount, len(mymergelist), pkg_key)
879 - emergelog(xterm_titles, msg, short_msg=short_msg)
880 -
881 - if retval != os.EX_OK:
882 - failed_fetches.append(pkg.cpv)
883 - if not fetchonly:
884 - raise self._pkg_failure()
885 -
886 - if "--fetchonly" in self.myopts or \
887 - "--fetch-all-uri" in self.myopts:
888 - self.curval += 1
889 - return
890 -
891 - short_msg = "emerge: ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[pkgindex]+" Merge Binary"
892 - emergelog(xterm_titles, " === ("+str(mergecount)+\
893 - " of "+str(len(mymergelist))+") Merging Binary ("+\
894 - x[pkgindex]+"::"+mytbz2+")", short_msg=short_msg)
895 - merge = BinpkgMerge(find_blockers=self._find_blockers(pkg),
896 - ldpath_mtimes=ldpath_mtimes, pkg=pkg, pretend=pretend,
897 - pkg_path=fetcher.pkg_path, settings=pkgsettings)
898 - retval = merge.execute()
899 - if retval != os.EX_OK:
900 - raise self._pkg_failure(retval)
901 - #need to check for errors
902 if not buildpkgonly:
903 if not (fetchonly or oneshot or pretend) and \
904 args_set.findAtomForPackage(pkg):
905 @@ -7321,7 +7396,7 @@
906 (mergecount, len(mymergelist), x[pkgindex])
907 emergelog(xterm_titles, (" === (%s of %s) " + \
908 "Post-Build Cleaning (%s::%s)") % \
909 - (mergecount, len(mymergelist), x[pkgindex], y),
910 + (mergecount, len(mymergelist), pkg.cpv, y),
911 short_msg=short_msg)
912 emergelog(xterm_titles, " ::: completed emerge ("+\
913 str(mergecount)+" of "+str(len(mymergelist))+") "+\
914
915 Modified: main/branches/prefix/pym/portage/__init__.py
916 ===================================================================
917 --- main/branches/prefix/pym/portage/__init__.py 2008-07-02 08:21:20 UTC (rev 10892)
918 +++ main/branches/prefix/pym/portage/__init__.py 2008-07-02 10:49:22 UTC (rev 10893)
919 @@ -170,7 +170,7 @@
920 if EmptyOnError:
921 return ""
922 else:
923 - raise KeyError, "Key not found in list; '%s'" % key
924 + raise KeyError("Key not found in list; '%s'" % key)
925
926 def getcwd():
927 "this fixes situations where the current directory doesn't exist"
928 @@ -1820,14 +1820,14 @@
929
930 def modifying(self):
931 if self.locked:
932 - raise Exception, "Configuration is locked."
933 + raise Exception("Configuration is locked.")
934
935 def backup_changes(self,key=None):
936 self.modifying()
937 if key and key in self.configdict["env"]:
938 self.backupenv[key] = copy.deepcopy(self.configdict["env"][key])
939 else:
940 - raise KeyError, "No such key defined in environment: %s" % key
941 + raise KeyError("No such key defined in environment: %s" % key)
942
943 def reset(self,keeping_pkg=0,use_cache=1):
944 """
945 @@ -6638,8 +6638,6 @@
946 return 1
947
948 tbz2_lock = None
949 - builddir_lock = None
950 - catdir_lock = None
951 mycat = None
952 mypkg = None
953 did_merge_phase = False
954 @@ -6682,12 +6680,7 @@
955 catdir_lock = portage.locks.lockdir(catdir)
956 portage.util.ensure_dirs(catdir,
957 uid=portage_uid, gid=portage_gid, mode=070, mask=0)
958 - builddir_lock = portage.locks.lockdir(builddir)
959 try:
960 - portage.locks.unlockdir(catdir_lock)
961 - finally:
962 - catdir_lock = None
963 - try:
964 shutil.rmtree(builddir)
965 except (IOError, OSError), e:
966 if e.errno != errno.ENOENT:
967 @@ -6764,7 +6757,7 @@
968 mysettings.pop("PORTAGE_BINPKG_FILE", None)
969 if tbz2_lock:
970 portage.locks.unlockfile(tbz2_lock)
971 - if builddir_lock:
972 + if True:
973 if not did_merge_phase:
974 # The merge phase handles this already. Callers don't know how
975 # far this function got, so we have to call elog_process() here
976 @@ -6778,21 +6771,6 @@
977 if e.errno != errno.ENOENT:
978 raise
979 del e
980 - portage.locks.unlockdir(builddir_lock)
981 - try:
982 - if not catdir_lock:
983 - # Lock catdir for removal if empty.
984 - catdir_lock = portage.locks.lockdir(catdir)
985 - finally:
986 - if catdir_lock:
987 - try:
988 - os.rmdir(catdir)
989 - except OSError, e:
990 - if e.errno not in (errno.ENOENT,
991 - errno.ENOTEMPTY, errno.EEXIST):
992 - raise
993 - del e
994 - portage.locks.unlockdir(catdir_lock)
995
996 def deprecated_profile_check():
997 if not os.access(DEPRECATED_PROFILE_FILE, os.R_OK):
998
999 Modified: main/branches/prefix/pym/portage/checksum.py
1000 ===================================================================
1001 --- main/branches/prefix/pym/portage/checksum.py 2008-07-02 08:21:20 UTC (rev 10892)
1002 +++ main/branches/prefix/pym/portage/checksum.py 2008-07-02 10:49:22 UTC (rev 10893)
1003 @@ -186,7 +186,10 @@
1004 myhash = perform_checksum(filename, x, calc_prelink=calc_prelink)[0]
1005 if mydict[x] != myhash:
1006 if strict:
1007 - raise portage.exception.DigestException, "Failed to verify '$(file)s' on checksum type '%(type)s'" % {"file":filename, "type":x}
1008 + raise portage.exception.DigestException(
1009 + ("Failed to verify '$(file)s' on " + \
1010 + "checksum type '%(type)s'") % \
1011 + {"file" : filename, "type" : x})
1012 else:
1013 file_is_ok = False
1014 reason = (("Failed on %s verification" % x), myhash,mydict[x])
1015
1016 Modified: main/branches/prefix/pym/portage/dbapi/porttree.py
1017 ===================================================================
1018 --- main/branches/prefix/pym/portage/dbapi/porttree.py 2008-07-02 08:21:20 UTC (rev 10892)
1019 +++ main/branches/prefix/pym/portage/dbapi/porttree.py 2008-07-02 10:49:22 UTC (rev 10893)
1020 @@ -263,11 +263,15 @@
1021 elif self.manifestVerifier:
1022 if not self.manifestVerifier.verify(myManifestPath):
1023 # Verification failed the desired level.
1024 - raise UntrustedSignature, "Untrusted Manifest: %(manifest)s" % {"manifest":myManifestPath}
1025 + raise UntrustedSignature(
1026 + "Untrusted Manifest: %(manifest)s" % \
1027 + {"manifest" : myManifestPath})
1028
1029 if ("severe" in self.mysettings.features) and \
1030 (mys != portage.gpg.fileStats(myManifestPath)):
1031 - raise SecurityViolation, "Manifest changed: %(manifest)s" % {"manifest":myManifestPath}
1032 + raise SecurityViolation(
1033 + "Manifest changed: %(manifest)s" % \
1034 + {"manifest":myManifestPath})
1035
1036 except InvalidSignature, e:
1037 if ("strict" in self.mysettings.features) or \
1038 @@ -284,7 +288,9 @@
1039 except (OSError, FileNotFound), e:
1040 if ("strict" in self.mysettings.features) or \
1041 ("severe" in self.mysettings.features):
1042 - raise SecurityViolation, "Error in verification of signatures: %(errormsg)s" % {"errormsg":str(e)}
1043 + raise SecurityViolation(
1044 + "Error in verification of signatures: " + \
1045 + "%(errormsg)s" % {"errormsg" : str(e)})
1046 writemsg("!!! Manifest is missing or inaccessable: %(manifest)s\n" % {"manifest":myManifestPath},
1047 noiselevel=-1)
1048
1049
1050 Modified: main/branches/prefix/pym/portage/dep.py
1051 ===================================================================
1052 --- main/branches/prefix/pym/portage/dep.py 2008-07-02 08:21:20 UTC (rev 10892)
1053 +++ main/branches/prefix/pym/portage/dep.py 2008-07-02 10:49:22 UTC (rev 10893)
1054 @@ -246,7 +246,7 @@
1055 if mydeparray:
1056 newdeparray.append(mydeparray.pop(0))
1057 else:
1058 - raise ValueError, "Conditional with no target."
1059 + raise ValueError("Conditional with no target.")
1060
1061 # Deprecation checks
1062 warned = 0
1063
1064 Modified: main/branches/prefix/pym/portage/getbinpkg.py
1065 ===================================================================
1066 --- main/branches/prefix/pym/portage/getbinpkg.py 2008-07-02 08:21:20 UTC (rev 10892)
1067 +++ main/branches/prefix/pym/portage/getbinpkg.py 2008-07-02 10:49:22 UTC (rev 10893)
1068 @@ -83,7 +83,8 @@
1069
1070 parts = baseurl.split("://",1)
1071 if len(parts) != 2:
1072 - raise ValueError, "Provided URL does not contain protocol identifier. '%s'" % baseurl
1073 + raise ValueError("Provided URL does not " + \
1074 + "contain protocol identifier. '%s'" % baseurl)
1075 protocol,url_parts = parts
1076 del parts
1077
1078 @@ -105,7 +106,7 @@
1079 del userpass_host
1080
1081 if len(userpass) > 2:
1082 - raise ValueError, "Unable to interpret username/password provided."
1083 + raise ValueError("Unable to interpret username/password provided.")
1084 elif len(userpass) == 2:
1085 username = userpass[0]
1086 password = userpass[1]
1087 @@ -324,7 +325,7 @@
1088 elif protocol == "sftp":
1089 listing = conn.listdir(address)
1090 else:
1091 - raise TypeError, "Unknown protocol. '%s'" % protocol
1092 + raise TypeError("Unknown protocol. '%s'" % protocol)
1093
1094 if not keepconnection:
1095 conn.close()
1096 @@ -356,7 +357,7 @@
1097 finally:
1098 f.close()
1099 else:
1100 - raise TypeError, "Unknown protocol. '%s'" % protocol
1101 + raise TypeError("Unknown protocol. '%s'" % protocol)
1102
1103 if data:
1104 xpaksize = portage.xpak.decodeint(data[-8:-4])
1105 @@ -448,7 +449,7 @@
1106 finally:
1107 f.close()
1108 else:
1109 - raise TypeError, "Unknown protocol. '%s'" % protocol
1110 + raise TypeError("Unknown protocol. '%s'" % protocol)
1111
1112 if not keepconnection:
1113 conn.close()
1114
1115 Modified: main/branches/prefix/pym/portage/gpg.py
1116 ===================================================================
1117 --- main/branches/prefix/pym/portage/gpg.py 2008-07-02 08:21:20 UTC (rev 10892)
1118 +++ main/branches/prefix/pym/portage/gpg.py 2008-07-02 10:49:22 UTC (rev 10893)
1119 @@ -10,6 +10,10 @@
1120 import commands
1121 import portage.exception
1122 import portage.checksum
1123 +from portage.exception import CommandNotFound, \
1124 + DirectoryNotFound, FileNotFound, \
1125 + InvalidData, InvalidDataType, InvalidSignature, MissingParameter, \
1126 + MissingSignature, PortageException, SecurityViolation
1127
1128 GPG_BINARY = "/usr/bin/gpg"
1129 GPG_OPTIONS = " --lock-never --no-random-seed-file --no-greeting --no-sig-cache "
1130 @@ -42,34 +46,38 @@
1131 if (keydir != None):
1132 # Verify that the keydir is valid.
1133 if type(keydir) != types.StringType:
1134 - raise portage.exception.InvalidDataType, "keydir argument: %s" % keydir
1135 + raise InvalidDataType(
1136 + "keydir argument: %s" % keydir)
1137 if not os.path.isdir(keydir):
1138 - raise portage.exception.DirectoryNotFound, "keydir: %s" % keydir
1139 + raise DirectoryNotFound("keydir: %s" % keydir)
1140 self.keydir = copy.deepcopy(keydir)
1141
1142 if (keyring != None):
1143 # Verify that the keyring is a valid filename and exists.
1144 if type(keyring) != types.StringType:
1145 - raise portage.exception.InvalidDataType, "keyring argument: %s" % keyring
1146 + raise InvalidDataType("keyring argument: %s" % keyring)
1147 if keyring.find("/") != -1:
1148 - raise portage.exception.InvalidData, "keyring: %s" % keyring
1149 + raise InvalidData("keyring: %s" % keyring)
1150 pathname = ""
1151 if keydir:
1152 pathname = keydir + "/" + keyring
1153 if not os.path.isfile(pathname):
1154 - raise portage.exception.FileNotFound, "keyring missing: %s (dev.gentoo.org/~carpaski/gpg/)" % pathname
1155 + raise FileNotFound(
1156 + "keyring missing: %s (dev.gentoo.org/~carpaski/gpg/)" % \
1157 + pathname)
1158
1159 keyringPath = keydir+"/"+keyring
1160
1161 if not keyring or not keyringPath and requireSignedRing:
1162 - raise portage.exception.MissingParameter
1163 + raise MissingParameter((keyring, keyringPath))
1164
1165 self.keyringStats = fileStats(keyringPath)
1166 self.minimumTrust = TRUSTED
1167 if not self.verify(keyringPath, keyringPath+".asc"):
1168 self.keyringIsTrusted = False
1169 if requireSignedRing:
1170 - raise portage.exception.InvalidSignature, "Required keyring verification: "+keyringPath
1171 + raise InvalidSignature(
1172 + "Required keyring verification: " + keyringPath)
1173 else:
1174 self.keyringIsTrusted = True
1175
1176 @@ -81,27 +89,27 @@
1177 if self.keyringStats and self.keyringPath:
1178 new_stats = fileStats(self.keyringPath)
1179 if new_stats != self.keyringStats:
1180 - raise portage.exception.SecurityViolation, "GPG keyring changed!"
1181 + raise SecurityViolation("GPG keyring changed!")
1182
1183 def verify(self, filename, sigfile=None):
1184 """Uses minimumTrust to determine if it is Valid/True or Invalid/False"""
1185 self._verifyKeyring()
1186
1187 if not os.path.isfile(filename):
1188 - raise portage.exception.FileNotFound, filename
1189 + raise FileNotFound, filename
1190
1191 if sigfile and not os.path.isfile(sigfile):
1192 - raise portage.exception.FileNotFound, sigfile
1193 + raise FileNotFound, sigfile
1194
1195 if self.keydir and not os.path.isdir(self.keydir):
1196 - raise portage.exception.DirectoryNotFound, filename
1197 + raise DirectoryNotFound, filename
1198
1199 if self.keyringPath:
1200 if not os.path.isfile(self.keyringPath):
1201 - raise portage.exception.FileNotFound, self.keyringPath
1202 + raise FileNotFound, self.keyringPath
1203
1204 if not os.path.isfile(filename):
1205 - raise portage.exception.CommandNotFound, filename
1206 + raise CommandNotFound(filename)
1207
1208 command = GPG_BINARY + GPG_VERIFY_FLAGS + GPG_OPTIONS
1209 if self.keydir:
1210 @@ -119,7 +127,7 @@
1211 result = (result >> 8)
1212
1213 if signal:
1214 - raise SignalCaught, "Signal: %d" % (signal)
1215 + raise PortageException("Signal: %d" % (signal))
1216
1217 trustLevel = UNTRUSTED
1218 if result == 0:
1219 @@ -127,22 +135,22 @@
1220 #if portage.output.find("WARNING") != -1:
1221 # trustLevel = MARGINAL
1222 if portage.output.find("BAD") != -1:
1223 - raise portage.exception.InvalidSignature, filename
1224 + raise InvalidSignature(filename)
1225 elif result == 1:
1226 trustLevel = EXISTS
1227 if portage.output.find("BAD") != -1:
1228 - raise portage.exception.InvalidSignature, filename
1229 + raise InvalidSignature(filename)
1230 elif result == 2:
1231 trustLevel = UNTRUSTED
1232 if portage.output.find("could not be verified") != -1:
1233 - raise portage.exception.MissingSignature, filename
1234 + raise MissingSignature(filename)
1235 if portage.output.find("public key not found") != -1:
1236 if self.keyringIsTrusted: # We trust the ring, but not the key specifically.
1237 trustLevel = MARGINAL
1238 else:
1239 - raise portage.exception.InvalidSignature, filename+" (Unknown Signature)"
1240 + raise InvalidSignature(filename+"(Unknown Signature)")
1241 else:
1242 - raise portage.exception.UnknownCondition, "GPG returned unknown result: %d" % (result)
1243 + raise PortageException("GPG returned unknown result: %d" % (result))
1244
1245 if trustLevel >= self.minimumTrust:
1246 return True
1247
1248 Modified: main/branches/prefix/pym/portage/locks.py
1249 ===================================================================
1250 --- main/branches/prefix/pym/portage/locks.py 2008-07-02 08:21:20 UTC (rev 10892)
1251 +++ main/branches/prefix/pym/portage/locks.py 2008-07-02 10:49:22 UTC (rev 10893)
1252 @@ -24,7 +24,7 @@
1253 import fcntl
1254
1255 if not mypath:
1256 - raise InvalidData, "Empty path given"
1257 + raise InvalidData("Empty path given")
1258
1259 if type(mypath) == types.StringType and mypath[-1] == '/':
1260 mypath = mypath[:-1]
1261 @@ -45,7 +45,7 @@
1262
1263 if type(mypath) == types.StringType:
1264 if not os.path.exists(os.path.dirname(mypath)):
1265 - raise DirectoryNotFound, os.path.dirname(mypath)
1266 + raise DirectoryNotFound(os.path.dirname(mypath))
1267 if not os.path.exists(lockfilename):
1268 old_mask=os.umask(000)
1269 myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR,0660)
1270 @@ -66,7 +66,8 @@
1271 myfd = mypath
1272
1273 else:
1274 - raise ValueError, "Unknown type passed in '%s': '%s'" % (type(mypath),mypath)
1275 + raise ValueError("Unknown type passed in '%s': '%s'" % \
1276 + (type(mypath), mypath))
1277
1278 # try for a non-blocking lock, if it's held, throw a message
1279 # we're waiting on lockfile and use a blocking attempt.
1280 @@ -166,7 +167,7 @@
1281 except OSError:
1282 if type(lockfilename) == types.StringType:
1283 os.close(myfd)
1284 - raise IOError, "Failed to unlock file '%s'\n" % lockfilename
1285 + raise IOError("Failed to unlock file '%s'\n" % lockfilename)
1286
1287 try:
1288 # This sleep call was added to allow other processes that are
1289 @@ -231,7 +232,9 @@
1290 os.close(myfd)
1291
1292 if not os.path.exists(myhardlock):
1293 - raise FileNotFound, _("Created lockfile is missing: %(filename)s") % {"filename":myhardlock}
1294 + raise FileNotFound(
1295 + _("Created lockfile is missing: %(filename)s") % \
1296 + {"filename" : myhardlock})
1297
1298 try:
1299 res = os.link(myhardlock, lockfilename)
1300
1301 --
1302 gentoo-commits@l.g.o mailing list