Return string from Package.__str__ (Bug 423209)
[gentoolkit.git] / bin / enalyze
1 #!/usr/bin/python
2 #
3 # Copyright 2010 Brian Dolbec <brian.dolbec@gmail.com>
4 # Copyright 2002-2010 Gentoo Technologies, Inc.
5 # Distributed under the terms of the GNU General Public License v2 or later
6 #
7 # $Header$
8
9 """'enalyze' is a flexible utility for Gentoo linux which can display various
10 information about installed packages, such as the USE flags used and the
11 packages that use them.  It can also be used to help rebuild /etc/portage/package.*
12 files in the event of corruption, and possibly more.
13 """
14
15 from __future__ import print_function
16
17 import sys
18 # This block ensures that ^C interrupts are handled quietly.
19 try:
20         import signal
21
22         def exithandler(signum,frame):
23                 signal.signal(signal.SIGINT, signal.SIG_IGN)
24                 signal.signal(signal.SIGTERM, signal.SIG_IGN)
25                 print()
26                 sys.exit(1)
27
28         signal.signal(signal.SIGINT, exithandler)
29         signal.signal(signal.SIGTERM, exithandler)
30         signal.signal(signal.SIGPIPE, signal.SIG_DFL)
31
32 except KeyboardInterrupt:
33         print()
34         sys.exit(1)
35
36 from gentoolkit import enalyze, errors
37
38 try:
39         enalyze.main()
40 except errors.GentoolkitException as err:
41         if '--debug' in sys.argv:
42                 raise
43         else:
44                 from gentoolkit import pprinter as pp
45                 sys.stderr.write(pp.error(str(err)))
46                 print()
47                 print("Add '--debug' to global options for traceback.")
48                 sys.exit(1)