try:
equery.main()
+except errors.GentoolkitNonZeroExit as err:
+ sys.exit(err.return_code)
except errors.GentoolkitException as err:
if '--debug' in sys.argv or bool(os.getenv('DEBUG', False)):
raise
.br
The fourth field, after the colon, is the package's slot. \fB0\fP is the default slot. To find all packages with multiple slots installed, use \fB\-\-duplicates\fP.
.P
-\fBNote:\fP Because it takes extra processing time to determine the location, mask status and slot, you can speed up output by passing the \fB\-\-quiet\fP global option to \fBequery\fP when you don't care about the extra information.
+\fBNote:\fP Because it takes extra processing time to determine the location, mask status and slot, you can speed up output by passing the \fB\-\-quiet\fP global option to \fBequery\fP when you don't care about the extra information.
+
+\fBNote:\fP Additionally, when using \-\-quiet, if no matches are found, instead of printing an error, the equery list module will return with an exit value of 3.
+>>>>>>> 61db505... Add gentoolkitNonZeroExit exception
.P
.I R "EXAMPLES" ":"
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
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"]:
'GentoolkitInvalidVersion',
'GentoolkitNoMatches',
'GentoolkitSetNotFound',
- 'GentoolkitUnknownKeyword'
+ 'GentoolkitUnknownKeyword',
+ 'GentoolkitNonZeroExit'
)
# ==========
"'%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: