Merge "Do not suppress all exceptions"

This commit is contained in:
Zuul 2017-10-17 20:18:46 +00:00 committed by Gerrit Code Review
commit 0cc9fdc61d

View File

@ -15,6 +15,7 @@
# limitations under the License. # limitations under the License.
from datetime import datetime from datetime import datetime
import errno
import json import json
import os.path import os.path
import pyghmi.constants as pygconst import pyghmi.constants as pygconst
@ -25,6 +26,7 @@ import pyghmi.ipmi.private.util as util
import pyghmi.ipmi.sdr as sdr import pyghmi.ipmi.sdr as sdr
import pyghmi.util.webclient as webclient import pyghmi.util.webclient as webclient
import random import random
import socket
import struct import struct
import threading import threading
import urllib import urllib
@ -137,7 +139,9 @@ class IMMClient(object):
wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv) wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv)
try: try:
wc.connect() wc.connect()
except Exception: except socket.error as se:
if se.errno != errno.ECONNREFUSED:
raise
return None return None
adata = urllib.urlencode({'user': self.username, adata = urllib.urlencode({'user': self.username,
'password': self.password, 'password': self.password,
@ -455,7 +459,9 @@ class XCCClient(IMMClient):
wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv) wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv)
try: try:
wc.connect() wc.connect()
except Exception: except socket.error as se:
if se.errno != errno.ECONNREFUSED:
raise
return None return None
adata = json.dumps({'username': self.username, adata = json.dumps({'username': self.username,
'password': self.password 'password': self.password