当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.LocationValueError方法代码示例

本文整理汇总了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)) 
开发者ID:gnosis,项目名称:django-eth-events,代码行数:23,代码来源:test_utils.py

示例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 
开发者ID:opencord,项目名称:voltha,代码行数:29,代码来源:download.py

示例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 
开发者ID:opencord,项目名称:voltha,代码行数:29,代码来源:download.py


注:本文中的urllib3.exceptions.LocationValueError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。