X-Git-Url: https://git.tld-linux.org/?a=blobdiff_plain;f=TLD_Builder%2Fmailer.py;h=5ccf63a0d3c00628ee6c974e8291aa0541a1dff5;hb=e6b6d095d23af595e207bb278697e1b9423fbc53;hp=f1459faf5c50f4e3cf377deda135e9e08d9d8f85;hpb=b999f53d4bf5d44586ecf028876e8bc20b5fd2ce;p=tld-builder.git diff --git a/TLD_Builder/mailer.py b/TLD_Builder/mailer.py index f1459fa..5ccf63a 100644 --- a/TLD_Builder/mailer.py +++ b/TLD_Builder/mailer.py @@ -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