summaryrefslogtreecommitdiffstats
path: root/bin/portageq
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-10-05 04:20:56 +0000
committerZac Medico <zmedico@gentoo.org>2007-10-05 04:20:56 +0000
commit4c2b32da48ddab172db68f90e1408f23026cd345 (patch)
tree3bfa6ac6b1fdf4f2ff70d53886cb5006e6e827db /bin/portageq
parent571988df251f484c9a632b98c14373d02e448a7c (diff)
downloadportage-4c2b32da48ddab172db68f90e1408f23026cd345.tar.gz
portage-4c2b32da48ddab172db68f90e1408f23026cd345.tar.bz2
portage-4c2b32da48ddab172db68f90e1408f23026cd345.zip
Bug #194764 - All the match* functions can raise
a ValueError if cpv_expand() receives an ambiguous atom. Therefore, move the ValueError handling code out of match() and use it to handle all such errors when appropriate. (trunk r7944) svn path=/main/branches/2.1.2/; revision=7945
Diffstat (limited to 'bin/portageq')
-rwxr-xr-xbin/portageq22
1 files changed, 13 insertions, 9 deletions
diff --git a/bin/portageq b/bin/portageq
index 6147e5627..4b9ad9473 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -184,15 +184,6 @@ def match(argv):
sys.exit(2)
try:
print "\n".join(portage.db[argv[0]]["vartree"].dbapi.match(argv[1]))
- except ValueError, e:
- # Multiple matches thrown from cpv_expand
- pkgs = e.args[0]
- # An error has occurred so we writemsg to stderr and exit nonzero.
- portage.writemsg("The following packages available:\n", noiselevel=-1)
- for pkg in pkgs:
- portage.writemsg("* %s\n" % pkg, noiselevel=-1)
- portage.writemsg("\nPlease use a more specific atom.\n", noiselevel=-1)
- sys.exit(1)
except KeyError, e:
portage.writemsg("%s\n" % str(e), noiselevel=-1)
sys.exit(1)
@@ -350,6 +341,19 @@ def main():
except portage_exception.PermissionDenied, e:
sys.stderr.write("Permission denied: '%s'\n" % str(e))
sys.exit(e.errno)
+ except ValueError, e:
+ if not e.args or \
+ not hasattr(e.args[0], "__len__") or \
+ len(e.args[0]) < 2:
+ raise
+ # Multiple matches thrown from cpv_expand
+ pkgs = e.args[0]
+ # An error has occurred so we writemsg to stderr and exit nonzero.
+ portage.writemsg("The following packages available:\n", noiselevel=-1)
+ for pkg in pkgs:
+ portage.writemsg("* %s\n" % pkg, noiselevel=-1)
+ portage.writemsg("\nPlease use a more specific atom.\n", noiselevel=-1)
+ sys.exit(1)
main()