2 # Copyright 2006-2011 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
5 from __future__ import print_function
9 # This block ensures that ^C interrupts are handled quietly.
12 def exithandler(signum,frame):
13 signal.signal(signal.SIGINT, signal.SIG_IGN)
14 signal.signal(signal.SIGTERM, signal.SIG_IGN)
15 sys.exit(128 + signum)
17 signal.signal(signal.SIGINT, exithandler)
18 signal.signal(signal.SIGTERM, exithandler)
19 # Prevent "[Errno 32] Broken pipe" exceptions when
21 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
23 except KeyboardInterrupt:
24 sys.exit(128 + signal.SIGINT)
26 def debug_signal(signum, frame):
29 signal.signal(signal.SIGUSR1, debug_signal)
32 from _emerge.main import emerge_main
34 from os import path as osp
36 sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
37 from _emerge.main import emerge_main
39 if __name__ == "__main__":
41 from portage.exception import ParseError, PermissionDenied
43 retval = emerge_main()
44 except PermissionDenied as e:
45 sys.stderr.write("Permission denied: '%s'\n" % str(e))
47 except ParseError as e:
48 sys.stderr.write("%s\n" % str(e))
53 # If an unexpected exception occurs then we don't want the mod_echo
54 # output to obscure the traceback, so dump the mod_echo output before
55 # showing the traceback.
57 tb_str = traceback.format_exc()
59 from portage.elog import mod_echo
64 sys.stderr.write(tb_str)