summaryrefslogtreecommitdiff
path: root/pym
diff options
context:
space:
mode:
authorPaul Varner <fuzzyray@gentoo.org>2011-01-06 08:22:07 -0600
committerPaul Varner <fuzzyray@gentoo.org>2011-01-06 09:48:52 -0600
commit63a5ccffaba120850b35814986e37c004c012de6 (patch)
tree5a113b5c0ce57de5d7064c24567734ca7bd2144f /pym
parent8d925c18b9694bff63eae4238eeac342a4589314 (diff)
downloadgentoolkit-63a5ccffaba120850b35814986e37c004c012de6.tar.gz
Add gentoolkitNonZeroExit exception
This exception should only be used when an error is not fatal and the absence of information means no data was found. The return_code parameter can be used to set the exit value. Have the equery list module when in quiet mode return an exit status of 3. This is needed to prevent 'euse -I' from printing many 'No installed packages matching ...' error messages.
Diffstat (limited to 'pym')
-rw-r--r--pym/gentoolkit/equery/list_.py6
-rw-r--r--pym/gentoolkit/errors.py11
2 files changed, 13 insertions, 4 deletions
diff --git a/pym/gentoolkit/equery/list_.py b/pym/gentoolkit/equery/list_.py
index 8c4b871..92b3c1e 100644
--- a/pym/gentoolkit/equery/list_.py
+++ b/pym/gentoolkit/equery/list_.py
@@ -19,7 +19,7 @@ from getopt import gnu_getopt, GetoptError
import gentoolkit
import gentoolkit.pprinter as pp
-import gentoolkit.errors as errors
+from gentoolkit import errors
from gentoolkit.equery import format_options, mod_usage, CONFIG
from gentoolkit.helpers import get_installed_cpvs
from gentoolkit.helpers import get_bintree_cpvs
@@ -193,14 +193,14 @@ def main(input_args):
print()
# if we are in quiet mode, do not raise GentoolkitNoMatches exception
- # TODO: Return a non-zero exit status
+ # instead we raise GentoolkitNonZeroExit to exit with an exit value of 3
try:
matches = query.smart_find(**QUERY_OPTS)
except errors.GentoolkitNoMatches:
if CONFIG['verbose']:
raise
else:
- continue
+ raise errors.GentoolkitNonZeroExit(3)
# Find duplicate packages
if QUERY_OPTS["duplicates"]:
diff --git a/pym/gentoolkit/errors.py b/pym/gentoolkit/errors.py
index 152f660..15fef24 100644
--- a/pym/gentoolkit/errors.py
+++ b/pym/gentoolkit/errors.py
@@ -16,7 +16,8 @@ __all__ = (
'GentoolkitInvalidVersion',
'GentoolkitNoMatches',
'GentoolkitSetNotFound',
- 'GentoolkitUnknownKeyword'
+ 'GentoolkitUnknownKeyword',
+ 'GentoolkitNonZeroExit'
)
# ==========
@@ -145,4 +146,12 @@ class GentoolkitUnknownKeyword(GentoolkitException):
"'%s', KEYWORDS = '%s'\nUSE flags = '%s'"
% (self.query, self.keywords, self.use))
+
+class GentoolkitNonZeroExit(GentoolkitException):
+ """Used to signal, that a non-fatal, no warning error occurred.
+ The primary use case is for not returning any data."""
+ def __init__(self, return_code=1, is_serious=False):
+ GentoolkitException.__init__(self, is_serious=is_serious)
+ self.return_code = return_code
+
# vim: set ts=4 sw=4 tw=79: