本文整理汇总了Python中urllib3.exceptions.LocationValueError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.LocationValueError方法的具体用法?Python exceptions.LocationValueError怎么用?Python exceptions.LocationValueError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urllib3.exceptions
的用法示例。
在下文中一共展示了exceptions.LocationValueError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_network_error_exception_detector
# 需要导入模块: from urllib3 import exceptions [as 别名]
# 或者: from urllib3.exceptions import LocationValueError [as 别名]
def test_network_error_exception_detector(self):
http_error = HTTPError()
self.assertTrue(is_network_error(http_error))
location_value_error = LocationValueError()
self.assertTrue(is_network_error(location_value_error))
pool_error = PoolError(None, 'an error')
self.assertTrue(is_network_error(pool_error))
exception = Exception()
self.assertFalse(is_network_error(exception))
w3_conn_error = Web3ConnectionException()
self.assertFalse(is_network_error(w3_conn_error))
setattr(w3_conn_error, 'errno', errno.ECONNABORTED)
self.assertTrue(is_network_error(w3_conn_error))
setattr(w3_conn_error, 'errno', errno.EPERM)
self.assertFalse(is_network_error(w3_conn_error))
示例2: parse_url
# 需要导入模块: from urllib3 import exceptions [as 别名]
# 或者: from urllib3.exceptions import LocationValueError [as 别名]
def parse_url(self):
from urllib3 import util, exceptions
try:
results = util.parse_url(self._url)
# Server info
self._scheme = results.scheme.lower()
if self._scheme not in self._supported_protocols:
self._failure_reason = ImageDownload.INVALID_URL
self._additional_info = "Unsupported file transfer protocol: {}".format(results.scheme)
return False
self._host = results.host
self._port = results.port
self._path = results.path
self._auth = results.auth
return True
except exceptions.LocationValueError as e:
self._failure_reason = ImageDownload.INVALID_URL
self._additional_info = e.message
return False
except Exception as e:
self._failure_reason = ImageDownload.UNKNOWN_ERROR
self._additional_info = e.message
return False
示例3: parse_url
# 需要导入模块: from urllib3 import exceptions [as 别名]
# 或者: from urllib3.exceptions import LocationValueError [as 别名]
def parse_url(self):
from urllib3 import util, exceptions
try:
results = util.parse_url(self._url)
# Server info
self._scheme = results.scheme.lower()
#if self._scheme not in self._supported_protocols:
#self._failure_reason = ImageDownload.INVALID_URL
#self._additional_info = "Unsupported file transfer protocol: {}".format(results.scheme)
#return False
self._host = results.host
self._port = results.port
self._path = results.path
self._auth = results.auth
return True
except exceptions.LocationValueError as e:
self._failure_reason = ImageDownload.INVALID_URL
self._additional_info = e.message
return False
except Exception as e:
self._failure_reason = ImageDownload.UNKNOWN_ERROR
self._additional_info = e.message
return False