This commit is contained in:
Dimitri John Ledkov 2014-12-18 20:48:28 +00:00
parent 1d2f7f6d0d
commit 3f512ee337

View File

@ -20,6 +20,8 @@
# Please see the /usr/share/common-licenses/GPL-2 file for the full text # Please see the /usr/share/common-licenses/GPL-2 file for the full text
# of the GNU General Public License license. # of the GNU General Public License license.
from __future__ import print_function
import os import os
import re import re
import sys import sys
@ -27,6 +29,10 @@ import smtplib
import socket import socket
import tempfile import tempfile
if sys.version_info[0] >= 3:
basestring = str
unicode = str
from debian.changelog import Changelog, Version from debian.changelog import Changelog, Version
from distro_info import DebianDistroInfo, DistroDataOutdated from distro_info import DebianDistroInfo, DistroDataOutdated
@ -51,7 +57,7 @@ def _get_srcpkg(distro, name, release):
debian_info = DebianDistroInfo() debian_info = DebianDistroInfo()
try: try:
release = debian_info.codename(release, default=release) release = debian_info.codename(release, default=release)
except DistroDataOutdated, e: except DistroDataOutdated as e:
Logger.warn(e) Logger.warn(e)
lines = list(rmadison(distro, name, suite=release, arch='source')) lines = list(rmadison(distro, name, suite=release, arch='source'))
@ -164,7 +170,7 @@ Content-Type: text/plain; charset=UTF-8
%s''' % (myemailaddr, to, bugtitle, signed_report) %s''' % (myemailaddr, to, bugtitle, signed_report)
print 'The final report is:\n%s' % mail print('The final report is:\n%s' % mail)
confirmation_prompt() confirmation_prompt()
# save mail in temporary file # save mail in temporary file
@ -184,11 +190,11 @@ Content-Type: text/plain; charset=UTF-8
mailserver_port) mailserver_port)
s = smtplib.SMTP(mailserver_host, mailserver_port) s = smtplib.SMTP(mailserver_host, mailserver_port)
break break
except socket.error, s: except socket.error as s:
Logger.error('Could not connect to %s:%s: %s (%i)', Logger.error('Could not connect to %s:%s: %s (%i)',
mailserver_host, mailserver_port, s[1], s[0]) mailserver_host, mailserver_port, s[1], s[0])
return return
except smtplib.SMTPConnectError, s: except smtplib.SMTPConnectError as s:
Logger.error('Could not connect to %s:%s: %s (%i)', Logger.error('Could not connect to %s:%s: %s (%i)',
mailserver_host, mailserver_port, s[1], s[0]) mailserver_host, mailserver_port, s[1], s[0])
if s.smtp_code == 421: if s.smtp_code == 421:
@ -215,7 +221,7 @@ Content-Type: text/plain; charset=UTF-8
os.remove(backup.name) os.remove(backup.name)
Logger.normal('Sync request mailed.') Logger.normal('Sync request mailed.')
break break
except smtplib.SMTPRecipientsRefused, smtperror: except smtplib.SMTPRecipientsRefused as smtperror:
smtp_code, smtp_message = smtperror.recipients[to] smtp_code, smtp_message = smtperror.recipients[to]
Logger.error('Error while sending: %i, %s', smtp_code, smtp_message) Logger.error('Error while sending: %i, %s', smtp_code, smtp_message)
if smtp_code == 450: if smtp_code == 450:
@ -223,7 +229,7 @@ Content-Type: text/plain; charset=UTF-8
'[Enter] to retry. Press [Ctrl-C] to abort now.') '[Enter] to retry. Press [Ctrl-C] to abort now.')
else: else:
return return
except smtplib.SMTPResponseException, e: except smtplib.SMTPResponseException as e:
Logger.error('Error while sending: %i, %s', Logger.error('Error while sending: %i, %s',
e.smtp_code, e.smtp_error) e.smtp_code, e.smtp_error)
return return