]> git.pld-linux.org Git - projects/pld-builder.new.git/blobdiff - 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
index 8d163343197b481526147df45ad92796e133b21f..b9809a3709f438e31684a6aad852e0c6378fcb96 100644 (file)
@@ -1,3 +1,5 @@
+# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+
 import sys
 import log
 import traceback
@@ -7,34 +9,48 @@ import time
 
 # 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())
-    
-    # don't use mailer.py; it safer this way
-    f = os.popen("/usr/sbin/sendmail -t", "w")
-    f.write("""Subject: builder failure
+try:
+    import mailer
+    def sendmail(trace):
+        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.get())
+        m.send()
+except:
+    def sendmail(trace):
+        # don't use mailer.py; it safer this way
+        f = os.popen("/usr/sbin/sendmail -i -t", "w")
+        f.write("""Subject: builder failure
 To: %s
-Cc: %s
+Cc: %s, %s
 Date: %s
 X-PLD-Builder: fatal error report
 
 %s
 
 during: %s
-""" % (status.admin, status.email, time.asctime(), s.getvalue(), status.get()))
-    f.close()
+""" % (status.admin, status.email, status.builder_list,
+             time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()),
+             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())
 
-    sys.exit(1)
+        sys.exit(1)
This page took 0.118423 seconds and 4 git commands to generate.