]> git.pld-linux.org Git - projects/pld-builder.new.git/blob - PLD_Builder/wrap.py
- include Date: and X-PLD-Builder: in emails
[projects/pld-builder.new.git] / PLD_Builder / wrap.py
1 import sys
2 import log
3 import traceback
4 import StringIO
5 import os
6 import time
7
8 # this module, as it deals with internal error handling shouldn't
9 # import anything beside status
10
11 import status
12
13 def wrap(main):
14   try:
15     main()
16   except:
17     exctype, value = sys.exc_info()[:2]
18     if exctype == SystemExit:
19       sys.exit(value)
20     s = StringIO.StringIO()
21     traceback.print_exc(file = s, limit = 20)
22     log.alert("fatal python exception")
23     log.alert(s.getvalue())
24     log.alert("during: %s" % status.get())
25     
26     # don't use mailer.py; it safer this way
27     f = os.popen("/usr/sbin/sendmail -t", "w")
28     f.write("""Subject: builder failure
29 To: %s
30 Cc: %s
31 Date: %s
32 X-PLD-Builder: fatal error report
33
34 %s
35
36 during: %s
37 """ % (status.admin, status.email, time.asctime(), s.getvalue(), status.get()))
38     f.close()
39
40     sys.exit(1)
This page took 0.03745 seconds and 4 git commands to generate.