Enable BytesWarnings.
[portage.git] / bin / emaint
1 #!/usr/bin/python -bbO
2 # Copyright 2005-2014 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 """System health checks and maintenance utilities.
6 """
7
8 from __future__ import print_function
9
10 import sys
11 import errno
12 # This block ensures that ^C interrupts are handled quietly.
13 try:
14         import signal
15
16         def exithandler(signum, _frame):
17                 signal.signal(signal.SIGINT, signal.SIG_IGN)
18                 signal.signal(signal.SIGTERM, signal.SIG_IGN)
19                 sys.exit(128 + signum)
20
21         signal.signal(signal.SIGINT, exithandler)
22         signal.signal(signal.SIGTERM, exithandler)
23         signal.signal(signal.SIGPIPE, signal.SIG_DFL)
24
25 except KeyboardInterrupt:
26         sys.exit(1)
27
28 from os import path as osp
29 pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")
30 sys.path.insert(0, pym_path)
31 import portage
32 portage._internal_caller = True
33 from portage.emaint.main import emaint_main
34
35 try:
36         emaint_main(sys.argv[1:])
37 except IOError as e:
38         if e.errno == errno.EACCES:
39                 print("\nemaint: Need superuser access")
40                 sys.exit(1)
41         else:
42                 raise