From 1d0e27423870066a4b18ee56f1aa661621a18c82 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 17 Oct 2017 13:18:45 -0400 Subject: [PATCH] Do not suppress all exceptions The only exception that is somewhat usual is connection refused, for systems without a web interface at all. Everything else should be raised. Change-Id: I2c6bd7f6a25a4728191748b071053112af3a2139 --- pyghmi/ipmi/oem/lenovo/imm.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 2f2e4783..335e107b 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -15,6 +15,7 @@ # limitations under the License. from datetime import datetime +import errno import json import os.path import pyghmi.constants as pygconst @@ -25,6 +26,7 @@ import pyghmi.ipmi.private.util as util import pyghmi.ipmi.sdr as sdr import pyghmi.util.webclient as webclient import random +import socket import struct import threading import urllib @@ -137,7 +139,9 @@ class IMMClient(object): wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv) try: wc.connect() - except Exception: + except socket.error as se: + if se.errno != errno.ECONNREFUSED: + raise return None adata = urllib.urlencode({'user': self.username, 'password': self.password, @@ -455,7 +459,9 @@ class XCCClient(IMMClient): wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv) try: wc.connect() - except Exception: + except socket.error as se: + if se.errno != errno.ECONNREFUSED: + raise return None adata = json.dumps({'username': self.username, 'password': self.password