requestsync: mail_bug: Catch socket.error (LP: #190739)

This commit is contained in:
Daniel Hahler 2008-04-16 02:25:33 +02:00
parent fd5479e548
commit 3f7c03a0e8
2 changed files with 8 additions and 1 deletions

1
debian/changelog vendored
View File

@ -14,6 +14,7 @@ ubuntu-dev-tools (0.31) hardy; urgency=low
- Do not fallback to submitting by email, if posting to Launchpad failed. - Do not fallback to submitting by email, if posting to Launchpad failed.
This hasn't been requested and therefore should not get done. This hasn't been requested and therefore should not get done.
- post_bug: Catch IOError when setting bug importance (LP: #190061) - post_bug: Catch IOError when setting bug importance (LP: #190061)
- mail_bug: Catch socket.error (LP: #190739)
-- Daniel Hahler <ubuntu@thequod.de> Wed, 16 Apr 2008 01:57:41 +0200 -- Daniel Hahler <ubuntu@thequod.de> Wed, 16 Apr 2008 01:57:41 +0200

View File

@ -127,6 +127,7 @@ def mail_bug(source_package, subscribe, status, bugtitle, bugtext, keyid = None)
Return True if email successfully send, otherwise False.''' Return True if email successfully send, otherwise False.'''
import smtplib import smtplib
import socket
to = 'new@bugs.launchpad.net' to = 'new@bugs.launchpad.net'
@ -192,7 +193,12 @@ def mail_bug(source_package, subscribe, status, bugtitle, bugtext, keyid = None)
mailserver_port = 25 mailserver_port = 25
# connect to the server # connect to the server
s = smtplib.SMTP(mailserver, mailserver_port) try:
s = smtplib.SMTP(mailserver, mailserver_port)
except socket.error, s:
print "ERROR: Could not connect to mailserver %s at port %s: %s (%i)" % \
(mailserver, mailserver_port, s[1], s[0])
return False
# authenticate to the server # authenticate to the server
mailserver_user = os.getenv('DEBSMTP_USER') mailserver_user = os.getenv('DEBSMTP_USER')