當前位置: 首頁>>代碼示例>>Python>>正文


Python client.getResolver方法代碼示例

本文整理匯總了Python中twisted.names.client.getResolver方法的典型用法代碼示例。如果您正苦於以下問題:Python client.getResolver方法的具體用法?Python client.getResolver怎麽用?Python client.getResolver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twisted.names.client的用法示例。


在下文中一共展示了client.getResolver方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_interface

# 需要導入模塊: from twisted.names import client [as 別名]
# 或者: from twisted.names.client import getResolver [as 別名]
def test_interface(self):
        """
        L{client.getResolver} returns an object providing L{IResolver}.
        """
        with AlternateReactor(Clock()):
            resolver = client.getResolver()
        self.assertTrue(verifyObject(IResolver, resolver)) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:9,代碼來源:test_client.py

示例2: test_idempotent

# 需要導入模塊: from twisted.names import client [as 別名]
# 或者: from twisted.names.client import getResolver [as 別名]
def test_idempotent(self):
        """
        Multiple calls to L{client.getResolver} return the same L{IResolver}
        implementation.
        """
        with AlternateReactor(Clock()):
            a = client.getResolver()
            b = client.getResolver()
        self.assertIs(a, b) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:11,代碼來源:test_client.py

示例3: _initResolver

# 需要導入模塊: from twisted.names import client [as 別名]
# 或者: from twisted.names.client import getResolver [as 別名]
def _initResolver():
    global DebugResolver
    if DebugResolver is None:
        if config.Scheduling.iSchedule.DNSDebug:
            DebugResolver = FakeBindAuthority(config.Scheduling.iSchedule.DNSDebug)
        else:
            DebugResolver = getResolver() 
開發者ID:apple,項目名稱:ccs-calendarserver,代碼行數:9,代碼來源:utils.py

示例4: __init__

# 需要導入模塊: from twisted.names import client [as 別名]
# 或者: from twisted.names.client import getResolver [as 別名]
def __init__(self):
        self.recs = {}
        
        self.resolver = client.getResolver() 
開發者ID:calston,項目名稱:tensor,代碼行數:6,代碼來源:utils.py

示例5: reverseResolve

# 需要導入模塊: from twisted.names import client [as 別名]
# 或者: from twisted.names.client import getResolver [as 別名]
def reverseResolve(
    ip: MaybeIPAddress, resolver: IResolver = None
) -> Optional[List[str]]:
    """Using the specified IResolver, reverse-resolves the specifed `ip`.

    :return: a sorted list of resolved hostnames (which the specified IP
        address reverse-resolves to). If the DNS lookup appeared to succeed,
        but no hostnames were found, returns an empty list. If the DNS lookup
        timed out or an error occurred, returns None.
    """
    if resolver is None:
        resolver = getResolver()
    ip = IPAddress(ip)
    try:
        data = yield resolver.lookupPointer(
            ip.reverse_dns, timeout=REVERSE_RESOLVE_RETRIES
        )
        # I love the concise way in which I can ask the Twisted data structure
        # what the list of hostnames is. This is great.
        results = sorted(
            (rr.payload.name.name.decode("idna") for rr in data[0]),
            key=preferred_hostnames_sort_key,
        )
    except AuthoritativeDomainError:
        # "Failed to reverse-resolve '%s': authoritative failure." % ip
        # This means the name didn't resolve, so return an empty list.
        return []
    except DomainError:
        # "Failed to reverse-resolve '%s': no records found." % ip
        # This means the name didn't resolve, so return an empty list.
        return []
    except DNSQueryTimeoutError:
        # "Failed to reverse-resolve '%s': timed out." % ip
        # Don't return an empty list since this implies a temporary failure.
        pass
    except ResolverError:
        # "Failed to reverse-resolve '%s': rejected by local resolver." % ip
        # Don't return an empty list since this could be temporary (unclear).
        pass
    else:
        return results
    return None 
開發者ID:maas,項目名稱:maas,代碼行數:44,代碼來源:network.py


注:本文中的twisted.names.client.getResolver方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。