1 |
commit: 3ffdbbe06fab5f3c60d03a77f5a2d08cb94b1869 |
2 |
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org> |
3 |
AuthorDate: Mon Nov 30 23:06:18 2015 +0000 |
4 |
Commit: Arfrever Frehtes Taifersar Arahesis <arfrever <AT> apache <DOT> org> |
5 |
CommitDate: Mon Nov 30 23:06:18 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3ffdbbe0 |
7 |
|
8 |
ebuild: Do not catch unexpected KeyErrors from aux_get(). |
9 |
|
10 |
bin/ebuild | 5 +++-- |
11 |
pym/portage/dbapi/porttree.py | 20 ++++++++++---------- |
12 |
pym/portage/exception.py | 5 ++++- |
13 |
3 files changed, 17 insertions(+), 13 deletions(-) |
14 |
|
15 |
diff --git a/bin/ebuild b/bin/ebuild |
16 |
index 59fced0..ed1231f 100755 |
17 |
--- a/bin/ebuild |
18 |
+++ b/bin/ebuild |
19 |
@@ -1,5 +1,5 @@ |
20 |
#!/usr/bin/python -bO |
21 |
-# Copyright 1999-2014 Gentoo Foundation |
22 |
+# Copyright 1999-2015 Gentoo Foundation |
23 |
# Distributed under the terms of the GNU General Public License v2 |
24 |
|
25 |
from __future__ import print_function |
26 |
@@ -49,6 +49,7 @@ from portage import _shell_quote |
27 |
from portage import _unicode_decode |
28 |
from portage import _unicode_encode |
29 |
from portage.const import VDB_PATH |
30 |
+from portage.exception import PortageKeyError |
31 |
from _emerge.Package import Package |
32 |
from _emerge.RootConfig import RootConfig |
33 |
|
34 |
@@ -273,7 +274,7 @@ try: |
35 |
metadata = dict(zip(Package.metadata_keys, |
36 |
portage.db[portage.settings['EROOT']][mytree].dbapi.aux_get( |
37 |
cpv, Package.metadata_keys, myrepo=myrepo))) |
38 |
-except KeyError: |
39 |
+except PortageKeyError: |
40 |
# aux_get failure, message should have been shown on stderr. |
41 |
sys.exit(1) |
42 |
|
43 |
|
44 |
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py |
45 |
index a954de5..23f3169 100644 |
46 |
--- a/pym/portage/dbapi/porttree.py |
47 |
+++ b/pym/portage/dbapi/porttree.py |
48 |
@@ -1,4 +1,4 @@ |
49 |
-# Copyright 1998-2014 Gentoo Foundation |
50 |
+# Copyright 1998-2015 Gentoo Foundation |
51 |
# Distributed under the terms of the GNU General Public License v2 |
52 |
|
53 |
from __future__ import unicode_literals |
54 |
@@ -23,7 +23,7 @@ from portage.cache import volatile |
55 |
from portage.cache.cache_errors import CacheError |
56 |
from portage.cache.mappings import Mapping |
57 |
from portage.dbapi import dbapi |
58 |
-from portage.exception import PortageException, \ |
59 |
+from portage.exception import PortageException, PortageKeyError, \ |
60 |
FileNotFound, InvalidAtom, InvalidData, \ |
61 |
InvalidDependString, InvalidPackageName |
62 |
from portage.localization import _ |
63 |
@@ -435,7 +435,7 @@ class portdbapi(dbapi): |
64 |
writemsg(_("!!! aux_get(): ebuild for " \ |
65 |
"'%s' does not exist at:\n") % (cpv,), noiselevel=-1) |
66 |
writemsg("!!! %s\n" % ebuild_path, noiselevel=-1) |
67 |
- raise KeyError(cpv) |
68 |
+ raise PortageKeyError(cpv) |
69 |
|
70 |
# Pull pre-generated metadata from the metadata/cache/ |
71 |
# directory if it exists and is valid, otherwise fall |
72 |
@@ -481,12 +481,12 @@ class portdbapi(dbapi): |
73 |
def aux_get(self, mycpv, mylist, mytree=None, myrepo=None): |
74 |
"stub code for returning auxilliary db information, such as SLOT, DEPEND, etc." |
75 |
'input: "sys-apps/foo-1.0",["SLOT","DEPEND","HOMEPAGE"]' |
76 |
- 'return: ["0",">=sys-libs/bar-1.0","http://www.foo.com"] or raise KeyError if error' |
77 |
+ 'return: ["0",">=sys-libs/bar-1.0","http://www.foo.com"] or raise PortageKeyError if error' |
78 |
cache_me = False |
79 |
if myrepo is not None: |
80 |
mytree = self.treemap.get(myrepo) |
81 |
if mytree is None: |
82 |
- raise KeyError(myrepo) |
83 |
+ raise PortageKeyError(myrepo) |
84 |
|
85 |
if mytree is not None and len(self.porttrees) == 1 \ |
86 |
and mytree == self.porttrees[0]: |
87 |
@@ -507,22 +507,22 @@ class portdbapi(dbapi): |
88 |
try: |
89 |
cat, pkg = mycpv.split("/", 1) |
90 |
except ValueError: |
91 |
- # Missing slash. Can't find ebuild so raise KeyError. |
92 |
- raise KeyError(mycpv) |
93 |
+ # Missing slash. Can't find ebuild so raise PortageKeyError. |
94 |
+ raise PortageKeyError(mycpv) |
95 |
|
96 |
myebuild, mylocation = self.findname2(mycpv, mytree) |
97 |
|
98 |
if not myebuild: |
99 |
writemsg("!!! aux_get(): %s\n" % \ |
100 |
_("ebuild not found for '%s'") % mycpv, noiselevel=1) |
101 |
- raise KeyError(mycpv) |
102 |
+ raise PortageKeyError(mycpv) |
103 |
|
104 |
mydata, ebuild_hash = self._pull_valid_cache(mycpv, myebuild, mylocation) |
105 |
doregen = mydata is None |
106 |
|
107 |
if doregen: |
108 |
if myebuild in self._broken_ebuilds: |
109 |
- raise KeyError(mycpv) |
110 |
+ raise PortageKeyError(mycpv) |
111 |
|
112 |
proc = EbuildMetadataPhase(cpv=mycpv, |
113 |
ebuild_hash=ebuild_hash, portdb=self, |
114 |
@@ -534,7 +534,7 @@ class portdbapi(dbapi): |
115 |
|
116 |
if proc.returncode != os.EX_OK: |
117 |
self._broken_ebuilds.add(myebuild) |
118 |
- raise KeyError(mycpv) |
119 |
+ raise PortageKeyError(mycpv) |
120 |
|
121 |
mydata = proc.metadata |
122 |
|
123 |
|
124 |
diff --git a/pym/portage/exception.py b/pym/portage/exception.py |
125 |
index 857a727..263cdf0 100644 |
126 |
--- a/pym/portage/exception.py |
127 |
+++ b/pym/portage/exception.py |
128 |
@@ -1,4 +1,4 @@ |
129 |
-# Copyright 1998-2014 Gentoo Foundation |
130 |
+# Copyright 1998-2015 Gentoo Foundation |
131 |
# Distributed under the terms of the GNU General Public License v2 |
132 |
|
133 |
import signal |
134 |
@@ -42,6 +42,9 @@ class PortageException(Exception): |
135 |
else: |
136 |
return repr(self.value) |
137 |
|
138 |
+class PortageKeyError(KeyError, PortageException): |
139 |
+ __doc__ = KeyError.__doc__ |
140 |
+ |
141 |
class CorruptionError(PortageException): |
142 |
"""Corruption indication""" |