pld-builder.new: PLD_Builder/mailer.py - handle 'weird' characters...

mmazur mmazur at pld-linux.org
Tue Jul 4 16:09:58 CEST 2006


Author: mmazur                       Date: Tue Jul  4 14:09:58 2006 GMT
Module: pld-builder.new               Tag: HEAD
---- Log message:
- handle 'weird' characters in buildlogs when sending out status mails
- TODO: change us-ascii to iso-8859-1

---- Files affected:
pld-builder.new/PLD_Builder:
   mailer.py (1.18 -> 1.19) 

---- Diffs:

================================================================
Index: pld-builder.new/PLD_Builder/mailer.py
diff -u pld-builder.new/PLD_Builder/mailer.py:1.18 pld-builder.new/PLD_Builder/mailer.py:1.19
--- pld-builder.new/PLD_Builder/mailer.py:1.18	Wed Sep 28 17:48:35 2005
+++ pld-builder.new/PLD_Builder/mailer.py	Tue Jul  4 16:09:53 2006
@@ -8,6 +8,12 @@
 from config import config
 import util
 
+def recode(s):
+    if s.__class__ == ''.__class__:
+        return s.decode('iso-8859-1', 'replace').encode('us-ascii', 'replace')
+    else:
+        return s.encode('us-ascii', 'replace')
+
 class Message:
     def __init__(self):
         self.headers = {}
@@ -26,10 +32,10 @@
             self.set_header("Subject", subject)
 
     def write_line(self, l):
-        self.body.write("%s\n" % l)
+        self.body.write(recode("%s\n" % l))
 
     def write(self, s):
-        self.body.write(s)
+        self.body.write(recode(s))
 
     def append_log(self, log):
         s = os.stat(log)
@@ -43,7 +49,7 @@
             line = 0
             for l in f.xreadlines():
                 if line < 100 or line > line_cnt - 100:
-                    self.body.write(l)
+                    self.body.write(recode(l))
                 if line == line_cnt - 100:
                     self.body.write("\n\n[...]\n\n")
                 line += 1
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/pld-builder.new/PLD_Builder/mailer.py?r1=1.18&r2=1.19&f=u



More information about the pld-cvs-commit mailing list