summaryrefslogtreecommitdiff
path: root/trunk/src
diff options
context:
space:
mode:
authorgenone <genone@gentoo.org>2004-01-23 03:35:08 +0000
committergenone <genone@gentoo.org>2004-01-23 03:35:08 +0000
commitf006e2ec9ff931a4a32b87349f2fa040afb4b662 (patch)
treec719ddf015db901d33e251bdca455ed160e56c91 /trunk/src
parent600418b2d4314cfb6ae6ca210de944f7b9e3d9cf (diff)
downloadgentoolkit-f006e2ec9ff931a4a32b87349f2fa040afb4b662.tar.gz
fixed Exception handling for other errors
svn path=/; revision=69
Diffstat (limited to 'trunk/src')
-rwxr-xr-xtrunk/src/equery/equery33
-rwxr-xr-xtrunk/src/etcat/etcat34
2 files changed, 44 insertions, 23 deletions
diff --git a/trunk/src/equery/equery b/trunk/src/equery/equery
index 099bc33..24d3aa3 100755
--- a/trunk/src/equery/equery
+++ b/trunk/src/equery/equery
@@ -17,6 +17,7 @@ import re
import sys
import time
import string
+import types
# portage (output module) and gentoolkit need special path modifications
sys.path.insert(0, "/usr/lib/portage/pym")
@@ -923,18 +924,28 @@ if __name__ == "__main__":
try:
cmd.perform(local_opts)
except KeyError, e:
- print red("!!!"), "Invalid syntax: missing operator"
- print red("!!!"), "If you want only specific versions please use one of"
- print red("!!!"), "the following operators as prefix for the package name:"
- print red("!!!"), " > >= = <= <"
- print red("!!!"), "Example to only match gcc versions greater or equal 3.2:"
- print red("!!!"), " >=sys-devel/gcc-3.2"
+ if string.find(e[0], "Specific key requires operator") == 0:
+ print red("!!!"), "Invalid syntax: missing operator"
+ print red("!!!"), "If you want only specific versions please use one of"
+ print red("!!!"), "the following operators as prefix for the package name:"
+ print red("!!!"), " > >= = <= <"
+ print red("!!!"), "Example to only match gcc versions greater or equal 3.2:"
+ print red("!!!"), " >=sys-devel/gcc-3.2"
+ else:
+ print red("!!!"), "Internal portage error, terminating"
+ if len(e[0]):
+ print red("!!!"), e
sys.exit(2)
- except ValueError, epkg:
- print red("!!!"), "Ambiguous package name \"%s\"" % query
- print red("!!!"), "Please use one of the following long names:"
- for p in epkg[0]:
- print red("!!!"), " "+p
+ except ValueError, e:
+ if type(e[0]) == types.ListType:
+ print red("!!!"), "Ambiguous package name \"%s\"" % query
+ print red("!!!"), "Please use one of the following long names:"
+ for p in e[0]:
+ print red("!!!"), " "+p
+ else:
+ print red("!!!"), "Internal portage error, terminating"
+ if len(e[0])):
+ print red("!!!"), e[0]
sys.exit(2)
else:
print "No command or unknown command given"
diff --git a/trunk/src/etcat/etcat b/trunk/src/etcat/etcat
index e5e726a..2ef5b9f 100755
--- a/trunk/src/etcat/etcat
+++ b/trunk/src/etcat/etcat
@@ -78,7 +78,7 @@
-import os,sys,string,re,pprint
+import os,sys,string,re,pprint,types
import getopt,glob
# portage and gentoolkit need special path modifications
@@ -631,18 +631,28 @@ def main():
try:
matches = gentoolkit.find_packages(query)
except KeyError, e:
- print red("!!!"), "Invalid syntax: missing operator"
- print red("!!!"), "If you want only specific versions please use one of"
- print red("!!!"), "the following operators as prefix for the package name:"
- print red("!!!"), " > >= = <= <"
- print red("!!!"), "Example to only match gcc versions greater or equal 3.2:"
- print red("!!!"), " >=sys-devel/gcc-3.2"
+ if string.find(e[0], "Specific key requires operator") == 0:
+ print red("!!!"), "Invalid syntax: missing operator"
+ print red("!!!"), "If you want only specific versions please use one of"
+ print red("!!!"), "the following operators as prefix for the package name:"
+ print red("!!!"), " > >= = <= <"
+ print red("!!!"), "Example to only match gcc versions greater or equal 3.2:"
+ print red("!!!"), " >=sys-devel/gcc-3.2"
+ else:
+ print red("!!!"), "Internal portage error, terminating"
+ if len(e[0]):
+ print red("!!!"), e
sys.exit(2)
- except ValueError, epkg:
- print red("!!!"), "Ambiguous package name \"%s\"" % query
- print red("!!!"), "Please use one of the following long names:"
- for p in epkg[0]:
- print red("!!!"), " "+p
+ except ValueError, e:
+ if type(e[0]) == types.ListType:
+ print red("!!!"), "Ambiguous package name \"%s\"" % query
+ print red("!!!"), "Please use one of the following long names:"
+ for p in e[0]:
+ print red("!!!"), " "+p
+ else:
+ print red("!!!"), "Internal portage error, terminating"
+ if len(e[0])):
+ print red("!!!"), e[0]
sys.exit(2)
function = globals()[action]
function(query, matches)