]> git.pld-linux.org Git - projects/pld-builder.new.git/blame - PLD_Builder/wrap.py
Switch to https for client/request handler server and between builders communication...
[projects/pld-builder.new.git] / PLD_Builder / wrap.py
CommitLineData
dfff8bd5
MM
1# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
2
6b44a683
MM
3import sys
4import log
5import traceback
6import StringIO
64a242eb 7import os
3f446d8f 8import time
64a242eb
MM
9
10# this module, as it deals with internal error handling shouldn't
11# import anything beside status
6b44a683
MM
12import status
13
7653a007
ER
14try:
15 import mailer
e79821e0 16 def sendmail(trace):
7653a007 17 m = mailer.Message()
e79821e0 18 m.set_headers(to = status.admin, cc = "%s, %s" % (status.email, status.builder_list), subject = "fatal python exception")
7653a007 19 m.write("%s\n" % trace)
e79821e0 20 m.write("during: %s\n" % status.get())
7653a007
ER
21 m.send()
22except:
e79821e0 23 def sendmail(trace):
dfff8bd5 24 # don't use mailer.py; it safer this way
8fa6edab 25 f = os.popen("/usr/sbin/sendmail -i -t", "w")
dfff8bd5 26 f.write("""Subject: builder failure
64a242eb 27To: %s
62ad2fa2 28Cc: %s, %s
75cb8915
MM
29Date: %s
30X-PLD-Builder: fatal error report
64a242eb
MM
31
32%s
33
34during: %s
7653a007 35""" % (status.admin, status.email, status.builder_list,
dfff8bd5 36 time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()),
7653a007 37 trace, status))
dfff8bd5 38 f.close()
64a242eb 39
7653a007
ER
40def wrap(main):
41 try:
42 main()
43 except:
44 exctype, value = sys.exc_info()[:2]
45 if exctype == SystemExit:
46 sys.exit(value)
47 s = StringIO.StringIO()
48 traceback.print_exc(file = s, limit = 20)
49
50 log.alert("fatal python exception")
51 log.alert(s.getvalue())
52 log.alert("during: %s" % status.get())
53
e79821e0 54 sendmail(s.getvalue())
7653a007 55
dfff8bd5 56 sys.exit(1)
This page took 0.428397 seconds and 4 git commands to generate.