2 # Copyright 2006-2012 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
5 from __future__ import print_function
10 # This block ensures that ^C interrupts are handled quietly.
13 def exithandler(signum,frame):
14 signal.signal(signal.SIGINT, signal.SIG_IGN)
15 signal.signal(signal.SIGTERM, signal.SIG_IGN)
16 sys.exit(128 + signum)
18 signal.signal(signal.SIGINT, exithandler)
19 signal.signal(signal.SIGTERM, exithandler)
20 # Prevent "[Errno 32] Broken pipe" exceptions when
22 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
24 except KeyboardInterrupt:
25 sys.exit(128 + signal.SIGINT)
27 def debug_signal(signum, frame):
31 if platform.python_implementation() == 'Jython':
32 debug_signum = signal.SIGUSR2 # bug #424259
34 debug_signum = signal.SIGUSR1
36 signal.signal(debug_signum, debug_signal)
39 from _emerge.main import emerge_main
41 from os import path as osp
43 sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
44 from _emerge.main import emerge_main
46 if __name__ == "__main__":
48 from portage.exception import ParseError, PermissionDenied
50 retval = emerge_main()
51 except PermissionDenied as e:
52 sys.stderr.write("Permission denied: '%s'\n" % str(e))
54 except ParseError as e:
55 sys.stderr.write("%s\n" % str(e))
60 # If an unexpected exception occurs then we don't want the mod_echo
61 # output to obscure the traceback, so dump the mod_echo output before
62 # showing the traceback.
64 tb_str = traceback.format_exc()
66 from portage.elog import mod_echo
71 sys.stderr.write(tb_str)