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
# 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:
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