]> TLD Linux GIT Repositories - tld-builder.git/blobdiff - TLD_Builder/mailer.py
- merged PLD changes, now it works with python 3.x
[tld-builder.git] / TLD_Builder / mailer.py
index f1459faf5c50f4e3cf377deda135e9e08d9d8f85..5ccf63a0d3c00628ee6c974e8291aa0541a1dff5 100644 (file)
@@ -3,7 +3,10 @@
 import time
 import os
 import sys
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 
 from config import config
 import util
@@ -48,11 +51,11 @@ class Message:
             # just head and tail
             f = open(log)
             line_cnt = 0
-            for l in f.xreadlines():
+            for l in f:
                 line_cnt += 1
             f.seek(0)
             line = 0
-            for l in f.xreadlines():
+            for l in f:
                 if line < 100 or line > line_cnt - 100:
                     self.body.write(recode(l))
                 if line == line_cnt - 100:
@@ -85,7 +88,7 @@ class Message:
         f = os.popen(send_sendmail, "w")
         try:
             self.write_to(f)
-        except IOError, e:
+        except IOError as e:
             log.alert("sending email message failed: %s" % e)
             f.close()
             return False