From 3f7c03a0e89fd6c6ae449e872e91491d8e5c51c6 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 16 Apr 2008 02:25:33 +0200 Subject: [PATCH] requestsync: mail_bug: Catch socket.error (LP: #190739) --- debian/changelog | 1 + requestsync | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 29ff599..4f2cfee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,7 @@ ubuntu-dev-tools (0.31) hardy; urgency=low - Do not fallback to submitting by email, if posting to Launchpad failed. This hasn't been requested and therefore should not get done. - post_bug: Catch IOError when setting bug importance (LP: #190061) + - mail_bug: Catch socket.error (LP: #190739) -- Daniel Hahler Wed, 16 Apr 2008 01:57:41 +0200 diff --git a/requestsync b/requestsync index 89b329b..f8b583f 100755 --- a/requestsync +++ b/requestsync @@ -127,6 +127,7 @@ def mail_bug(source_package, subscribe, status, bugtitle, bugtext, keyid = None) Return True if email successfully send, otherwise False.''' import smtplib + import socket to = 'new@bugs.launchpad.net' @@ -192,7 +193,12 @@ def mail_bug(source_package, subscribe, status, bugtitle, bugtext, keyid = None) mailserver_port = 25 # 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 mailserver_user = os.getenv('DEBSMTP_USER')