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


Python exceptions.LocationParseError方法代码示例

本文整理汇总了Python中urllib3.exceptions.LocationParseError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.LocationParseError方法的具体用法?Python exceptions.LocationParseError怎么用?Python exceptions.LocationParseError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urllib3.exceptions的用法示例。


在下文中一共展示了exceptions.LocationParseError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from urllib3 import exceptions [as 别名]
# 或者: from urllib3.exceptions import LocationParseError [as 别名]
def __init__(
            self, base_url, token=None, identity=None,
            default_429_wait_ms=5000,
            use_authorization_header=True,
            connection_timeout=60
    ):
        try:
            scheme, auth, host, port, path, query, fragment = parse_url(base_url)
        except LocationParseError:
            raise MatrixError("Invalid homeserver url %s" % base_url)
        if not scheme:
            raise MatrixError("No scheme in homeserver url %s" % base_url)
        self._base_url = base_url

        self.token = token
        self.identity = identity
        self.txn_id = 0
        self.validate_cert = True
        self.session = Session()
        self.default_429_wait_ms = default_429_wait_ms
        self.use_authorization_header = use_authorization_header
        self.connection_timeout = connection_timeout 
开发者ID:saadnpq,项目名称:matrixcli,代码行数:24,代码来源:api.py

示例2: __init__

# 需要导入模块: from urllib3 import exceptions [as 别名]
# 或者: from urllib3.exceptions import LocationParseError [as 别名]
def __init__(
            self, base_url, token=None, identity=None,
            default_429_wait_ms=5000,
            use_authorization_header=True
    ):
        try:
            scheme, auth, host, port, path, query, fragment = parse_url(base_url)
        except LocationParseError:
            raise MatrixError("Invalid homeserver url %s" % base_url)
        if not scheme:
            raise MatrixError("No scheme in homeserver url %s" % base_url)
        self._base_url = base_url

        self.token = token
        self.identity = identity
        self.txn_id = 0
        self.validate_cert = True
        self.session = Session()
        self.default_429_wait_ms = default_429_wait_ms
        self.use_authorization_header = use_authorization_header 
开发者ID:matrix-org,项目名称:matrix-python-sdk,代码行数:22,代码来源:api.py

示例3: get_schema_and_host

# 需要导入模块: from urllib3 import exceptions [as 别名]
# 或者: from urllib3.exceptions import LocationParseError [as 别名]
def get_schema_and_host(
    url: str, require_url_encoding: bool = False
) -> Tuple[Optional[str], Optional[str], Optional[str]]:
    """
    Return URL scheme and host and cleaned URL.

    Parameters
    ----------
    url : str
        Input URL
    require_url_encoding : bool
        Set to True if url needs encoding. Defualt is False.

    Returns
    -------
    Tuple[Optional[str], Optional[str], Optional[str]
        Tuple of URL, scheme, host

    """
    clean_url = None
    scheme = None
    host = None
    try:
        scheme, _, host, _, _, _, _ = parse_url(url)
        clean_url = url
    except LocationParseError:
        # Try to clean URL and re-check
        cleaned_url = _clean_url(url)
        if cleaned_url is not None:
            try:
                scheme, _, host, _, _, _, _ = parse_url(cleaned_url)
                clean_url = cleaned_url
            except LocationParseError:
                pass
    if require_url_encoding and clean_url:
        clean_url = quote_plus(clean_url)
    return clean_url, scheme, host 
开发者ID:microsoft,项目名称:msticpy,代码行数:39,代码来源:ti_provider_base.py

示例4: crawl

# 需要导入模块: from urllib3 import exceptions [as 别名]
# 或者: from urllib3.exceptions import LocationParseError [as 别名]
def crawl(self):
        """
        Collects links from our root urls, stores them and then calls
        `_browse_from_links` to browse them
        """
        self._start_time = datetime.datetime.now()

        while True:
            url = random.choice(self._config["root_urls"])
            try:
                body = self._request(url).content
                self._links = self._extract_urls(body, url)
                logging.debug("found {} links".format(len(self._links)))
                self._browse_from_links()

            except requests.exceptions.RequestException:
                logging.warn("Error connecting to root url: {}".format(url))
                
            except MemoryError:
                logging.warn("Error: content at url: {} is exhausting the memory".format(url))

            except LocationParseError:
                logging.warn("Error encountered during parsing of: {}".format(url))

            except self.CrawlerTimedOut:
                logging.info("Timeout has exceeded, exiting")
                return 
开发者ID:1tayH,项目名称:noisy,代码行数:29,代码来源:noisy.py

示例5: test_wrong_host_format

# 需要导入模块: from urllib3 import exceptions [as 别名]
# 或者: from urllib3.exceptions import LocationParseError [as 别名]
def test_wrong_host_format(self):
        parser = get_parser()
        args = parser.parse_args([
            "--hosts", "localhost:12AB"
        ])

        crate_hosts = [host_and_port(h) for h in args.hosts]

        with self.assertRaises(LocationParseError):
            _create_shell(crate_hosts, False, None, False, args) 
开发者ID:crate,项目名称:crash,代码行数:12,代码来源:test_integration.py


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