From 4023eb974afd049602cbc48b0a85b2caa6eaaac1 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 28 Jan 2015 09:31:11 -0700 Subject: [PATCH] Add error message when SMTP server is unreachable This only happens when scheduling fails. Signed-off-by: Zack Cerza --- teuthology/suite.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/teuthology/suite.py b/teuthology/suite.py index 34c7971487..3170b52851 100644 --- a/teuthology/suite.py +++ b/teuthology/suite.py @@ -11,6 +11,7 @@ import requests import pwd import subprocess import smtplib +import socket import sys import yaml from email.mime.text import MIMEText @@ -308,9 +309,12 @@ def schedule_fail(message, name=''): msg['Subject'] = subject msg['From'] = config.results_sending_email msg['To'] = email - smtp = smtplib.SMTP('localhost') - smtp.sendmail(msg['From'], [msg['To']], msg.as_string()) - smtp.quit() + try: + smtp = smtplib.SMTP('localhost') + smtp.sendmail(msg['From'], [msg['To']], msg.as_string()) + smtp.quit() + except socket.error: + log.exception("Failed to connect to mail server!") raise ScheduleFailError(message, name) -- 2.39.5