sb: Update code base to support Python3 and Python2.

Fix Windows support to allow MSYS2 Python to be used.

Updates #2619.
This commit is contained in:
Chris Johns
2016-03-07 11:56:02 +11:00
parent b537e55364
commit 3a972f6102
29 changed files with 412 additions and 314 deletions

View File

@@ -21,6 +21,8 @@
# Manage emailing results or reports.
#
from __future__ import print_function
import os
import smtplib
import socket
@@ -64,7 +66,7 @@ class mail:
mrc = open(mailrc, 'r')
lines = mrc.readlines()
mrc.close()
except IOError, err:
except IOError as err:
raise error.general('error reading: %s' % (mailrc))
for l in lines:
l = _clean(l)
@@ -93,9 +95,9 @@ class mail:
try:
s = smtplib.SMTP(self.smtp_host())
s.sendmail(from_addr, [to_addr], msg)
except smtplib.SMTPException, se:
except smtplib.SMTPException as se:
raise error.general('sending mail: %s' % (str(se)))
except socket.error, se:
except socket.error as se:
raise error.general('sending mail: %s' % (str(se)))
if __name__ == '__main__':
@@ -104,6 +106,6 @@ if __name__ == '__main__':
append_options(optargs)
opts = options.load(sys.argv, optargs = optargs, defaults = 'defaults.mc')
m = mail(opts)
print 'From: %s' % (m.from_address())
print 'SMTP Host: %s' % (m.smtp_host())
print('From: %s' % (m.from_address()))
print('SMTP Host: %s' % (m.smtp_host()))
m.send(m.from_address(), 'Test mailer.py', 'This is a test')