本文整理汇总了Python中_ssl.SSLError方法的典型用法代码示例。如果您正苦于以下问题:Python _ssl.SSLError方法的具体用法?Python _ssl.SSLError怎么用?Python _ssl.SSLError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_ssl
的用法示例。
在下文中一共展示了_ssl.SSLError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send
# 需要导入模块: import _ssl [as 别名]
# 或者: from _ssl import SSLError [as 别名]
def send(self, data, flags=0):
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to send() on %s" %
self.__class__)
while True:
try:
v = self._sslobj.write(data)
except SSLError, x:
if x.args[0] == SSL_ERROR_WANT_READ:
return 0
elif x.args[0] == SSL_ERROR_WANT_WRITE:
return 0
else:
raise
else:
return v
示例2: read
# 需要导入模块: import _ssl [as 别名]
# 或者: from _ssl import SSLError [as 别名]
def read(self, len=1024):
"""Read up to LEN bytes and return them.
Return zero-length string on EOF."""
try:
return self._sslobj.read(len)
except SSLError, x:
if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
return ''
else:
raise
示例3: test_SSLError
# 需要导入模块: import _ssl [as 别名]
# 或者: from _ssl import SSLError [as 别名]
def test_SSLError(self):
self.assertEqual(real_ssl.SSLError.__bases__, (socket.error, ))
示例4: test_SSLType_ssl_neg
# 需要导入模块: import _ssl [as 别名]
# 或者: from _ssl import SSLError [as 别名]
def test_SSLType_ssl_neg(self):
'''
See comments on test_SSLType_ssl. Basically this needs to be revisited
entirely (TODO) after we're more compatible with CPython.
'''
s = socket.socket(socket.AF_INET)
s.connect((SSL_URL, SSL_PORT))
#--Negative
#Empty
self.assertRaises(TypeError, real_ssl.sslwrap)
self.assertRaises(TypeError, real_ssl.sslwrap, False)
#None
self.assertRaises(TypeError, real_ssl.sslwrap, None, False)
#s, bad keyfile
#Should throw _ssl.SSLError because both keyfile and certificate weren't specified
self.assertRaises(real_ssl.SSLError, real_ssl.sslwrap, s._sock, False, "bad keyfile")
#s, bad certfile
#Should throw _ssl.SSLError because both keyfile and certificate weren't specified
#s, bad keyfile, bad certfile
#Should throw ssl.SSLError
self.assertRaises(real_ssl.SSLError, real_ssl.sslwrap, s._sock, False, "bad keyfile", "bad certfile")
#Cleanup
s.close()
示例5: get_content
# 需要导入模块: import _ssl [as 别名]
# 或者: from _ssl import SSLError [as 别名]
def get_content(self, page, url):
"""
:return: Content if present, None on handled exception
"""
try:
content = page.read()
except (socket.timeout, six.moves.http_client.HTTPException, SSLError) as e:
logging.info("Exception while reading %s, terminating: %s", url, tools.error_to_str(e))
return None
return content
示例6: test_SSLError
# 需要导入模块: import _ssl [as 别名]
# 或者: from _ssl import SSLError [as 别名]
def test_SSLError(self):
self.assertEqual(_ssl.SSLError.__bases__, (socket.error, ))
示例7: test_SSLType_ssl_neg
# 需要导入模块: import _ssl [as 别名]
# 或者: from _ssl import SSLError [as 别名]
def test_SSLType_ssl_neg(self):
'''
See comments on test_SSLType_ssl. Basically this needs to be revisited
entirely (TODO) after we're more compatible with CPython.
'''
s = socket.socket(socket.AF_INET)
s.connect((SSL_URL, SSL_PORT))
#--Negative
#Empty
self.assertRaises(TypeError, _ssl.sslwrap)
self.assertRaises(TypeError, _ssl.sslwrap, False)
#None
self.assertRaises(TypeError, _ssl.sslwrap, None, False)
#s, bad keyfile
#Should throw _ssl.SSLError because both keyfile and certificate weren't specified
#s, bad certfile
#Should throw _ssl.SSLError because both keyfile and certificate weren't specified
#s, bad keyfile, bad certfile
#Should throw ssl.SSLError
self.assertRaises(_ssl.SSLError, _ssl.sslwrap, s, False, "bad keyfile", "bad certfile")
#Cleanup
s.close()
示例8: addGeoServerCatalog
# 需要导入模块: import _ssl [as 别名]
# 或者: from _ssl import SSLError [as 别名]
def addGeoServerCatalog(self, explorer):
dlg = DefineCatalogDialog(self._catalogs)
dlg.exec_()
if dlg.ok:
try:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
if dlg.authid:
cache_time = pluginSetting("AuthCatalogXMLCacheTime")
cat = AuthCatalog(dlg.url, dlg.authid, cache_time)
self.catalog = cat
else:
cat = BaseCatalog(dlg.url, dlg.username, dlg.password)
cat.authid = dlg.authid
v = cat.gsversion()
try:
major = int(v.split(".")[0])
minor = int(v.split(".")[1])
supported = major > 2 or (major == 2 and minor > 2)
except:
supported = False
if not supported:
QApplication.restoreOverrideCursor()
ret = QMessageBox.warning(explorer, "GeoServer catalog definition",
"The specified catalog seems to be running an older\n"
"or unidentified version of GeoServer.\n"
"That might cause unexpected behaviour.\nDo you want to add the catalog anyway?",
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No);
if ret == QMessageBox.No:
return
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
geoserverItem = GsCatalogItem(cat, dlg.name)
self.addChild(geoserverItem)
geoserverItem.populate()
self.setExpanded(True)
except FailedRequestError as e:
setError("Error connecting to server (See log for more details)", traceback.format_exc())
except SSLError:
setWarning("Cannot connect using the provided certificate/key values")
except Exception as e:
setError("Could not connect to catalog", traceback.format_exc())
finally:
QApplication.restoreOverrideCursor()