pld-builder.new: PLD_Builder/wrap.py - still do use mailer.py (fallback to ...
glen
glen at pld-linux.org
Mon Feb 16 12:22:03 CET 2009
Author: glen Date: Mon Feb 16 11:22:03 2009 GMT
Module: pld-builder.new Tag: HEAD
---- Log message:
- still do use mailer.py (fallback to without) to get proper mail headers set
---- Files affected:
pld-builder.new/PLD_Builder:
wrap.py (1.8 -> 1.9)
---- Diffs:
================================================================
Index: pld-builder.new/PLD_Builder/wrap.py
diff -u pld-builder.new/PLD_Builder/wrap.py:1.8 pld-builder.new/PLD_Builder/wrap.py:1.9
--- pld-builder.new/PLD_Builder/wrap.py:1.8 Wed Sep 28 17:48:35 2005
+++ pld-builder.new/PLD_Builder/wrap.py Mon Feb 16 12:21:57 2009
@@ -9,22 +9,18 @@
# this module, as it deals with internal error handling shouldn't
# import anything beside status
-
import status
-def wrap(main):
- try:
- main()
- except:
- exctype, value = sys.exc_info()[:2]
- if exctype == SystemExit:
- sys.exit(value)
- s = StringIO.StringIO()
- traceback.print_exc(file = s, limit = 20)
- log.alert("fatal python exception")
- log.alert(s.getvalue())
- log.alert("during: %s" % status.get())
-
+try:
+ import mailer
+ def sendmail(trace, status):
+ m = mailer.Message()
+ m.set_headers(to = status.admin, cc = ("%s, %s" % status.email, status.builder_list), subject = "fatal python exception")
+ m.write("%s\n" % trace)
+ m.write("during: %s\n" % status)
+ m.send()
+except:
+ def sendmail(trace, status):
# don't use mailer.py; it safer this way
f = os.popen("/usr/sbin/sendmail -i -t", "w")
f.write("""Subject: builder failure
@@ -36,9 +32,25 @@
%s
during: %s
-""" % (status.admin, status.email, status.builder_list,
+""" % (status.admin, status.email, status.builder_list,
time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()),
- s.getvalue(), status.get()))
+ trace, status))
f.close()
+
+def wrap(main):
+ try:
+ main()
+ except:
+ exctype, value = sys.exc_info()[:2]
+ if exctype == SystemExit:
+ sys.exit(value)
+ s = StringIO.StringIO()
+ traceback.print_exc(file = s, limit = 20)
+
+ log.alert("fatal python exception")
+ log.alert(s.getvalue())
+ log.alert("during: %s" % status.get())
+
+ sendmail(s.getvalue(), status.get())
sys.exit(1)
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-builder.new/PLD_Builder/wrap.py?r1=1.8&r2=1.9&f=u
More information about the pld-cvs-commit
mailing list