SRU ADT regression: handle errors in sendmail.

sru-messages-fixes
Łukasz 'sil2100' Zemczak 6 years ago
parent 1cbc21d258
commit d21bd600cc

@ -1,5 +1,6 @@
import os import os
import json import json
import socket
import smtplib import smtplib
from urllib.request import urlopen, URLError from urllib.request import urlopen, URLError
@ -106,7 +107,12 @@ class SRUADTRegressionPolicy(BasePolicy, Rest):
bugs = self.bugs_from_changes(changes_url) bugs = self.bugs_from_changes(changes_url)
# Now leave a comment informing about the ADT regressions on each bug # Now leave a comment informing about the ADT regressions on each bug
for bug in bugs: for bug in bugs:
self.log('%sSending ADT regression message to LP: #%s '
'regarding %s/%s in %s' % (
"[dry-run] " if self.dry_run else "", bug,
source_name, version, series_name))
if not self.dry_run: if not self.dry_run:
try:
bug_mail = '%s@bugs.launchpad.net' % bug bug_mail = '%s@bugs.launchpad.net' % bug
server = smtplib.SMTP(self.email_host) server = smtplib.SMTP(self.email_host)
server.sendmail( server.sendmail(
@ -114,10 +120,9 @@ class SRUADTRegressionPolicy(BasePolicy, Rest):
bug_mail, bug_mail,
MESSAGE.format(**locals())) MESSAGE.format(**locals()))
server.quit() server.quit()
self.log('%sSending ADT regression message to LP: #%s ' except socket.error as err:
'regarding %s/%s in %s' % ( self.log('Failed to send mail! Is SMTP server running?')
"[dry-run] " if self.dry_run else "", bug, self.log(err)
source_name, version, series_name))
self.save_progress(source_name, version, distro_name, series_name) self.save_progress(source_name, version, distro_name, series_name)
return PolicyVerdict.PASS return PolicyVerdict.PASS

Loading…
Cancel
Save