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


Python socket.errorTab方法代碼示例

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


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

示例1: fromEnvironment

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import errorTab [as 別名]
def fromEnvironment(cls):
        """
        Get as many of the platform-specific error translation objects as
        possible and return an instance of C{cls} created with them.
        """
        try:
            from ctypes import WinError
        except ImportError:
            WinError = None
        try:
            from win32api import FormatMessage
        except ImportError:
            FormatMessage = None
        try:
            from socket import errorTab
        except ImportError:
            errorTab = None
        return cls(WinError, FormatMessage, errorTab) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:20,代碼來源:win32.py

示例2: formatError

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import errorTab [as 別名]
def formatError(self, errorcode):
        """
        Returns the string associated with a Windows error message, such as the
        ones found in socket.error.

        Attempts direct lookup against the win32 API via ctypes and then
        pywin32 if available), then in the error table in the socket module,
        then finally defaulting to C{os.strerror}.

        @param errorcode: the Windows error code
        @type errorcode: C{int}

        @return: The error message string
        @rtype: C{str}
        """
        if self.winError is not None:
            return self.winError(errorcode).strerror
        if self.formatMessage is not None:
            return self.formatMessage(errorcode)
        if self.errorTab is not None:
            result = self.errorTab.get(errorcode)
            if result is not None:
                return result
        return os.strerror(errorcode) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:26,代碼來源:win32.py

示例3: test_correctLookups

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import errorTab [as 別名]
def test_correctLookups(self):
        """
        Given a known-good errno, make sure that formatMessage gives results
        matching either C{socket.errorTab}, C{ctypes.WinError}, or
        C{win32api.FormatMessage}.
        """
        acceptable = [socket.errorTab[ECONNABORTED]]
        try:
            from ctypes import WinError
            acceptable.append(WinError(ECONNABORTED).strerror)
        except ImportError:
            pass
        try:
            from win32api import FormatMessage
            acceptable.append(FormatMessage(ECONNABORTED))
        except ImportError:
            pass

        self.assertIn(formatError(ECONNABORTED), acceptable) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:21,代碼來源:test_strerror.py

示例4: formatError

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import errorTab [as 別名]
def formatError(self, errorcode):
        """
        Returns the string associated with a Windows error message, such as the
        ones found in socket.error.

        Attempts direct lookup against the win32 API via ctypes and then
        pywin32 if available), then in the error table in the socket module,
        then finally defaulting to C{os.strerror}.

        @param errorcode: the Windows error code
        @type errorcode: C{int}

        @return: The error message string
        @rtype: C{str}
        """
        if self.winError is not None:
            return str(self.winError(errorcode))
        if self.formatMessage is not None:
            return self.formatMessage(errorcode)
        if self.errorTab is not None:
            result = self.errorTab.get(errorcode)
            if result is not None:
                return result
        return os.strerror(errorcode) 
開發者ID:leancloud,項目名稱:satori,代碼行數:26,代碼來源:win32util.py

示例5: formatError

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import errorTab [as 別名]
def formatError(self, errorcode):
        """
        Returns the string associated with a Windows error message, such as the
        ones found in socket.error.

        Attempts direct lookup against the win32 API via ctypes and then
        pywin32 if available), then in the error table in the socket module,
        then finally defaulting to C{os.strerror}.

        @param errorcode: the Windows error code
        @type errorcode: C{int}

        @return: The error message string
        @rtype: C{str}
        """
        if self.winError is not None:
            return self.winError(errorcode)[1]
        if self.formatMessage is not None:
            return self.formatMessage(errorcode)
        if self.errorTab is not None:
            result = self.errorTab.get(errorcode)
            if result is not None:
                return result
        return os.strerror(errorcode) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:26,代碼來源:win32.py

示例6: test_correctLookups

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import errorTab [as 別名]
def test_correctLookups(self):
        """
        Given an known-good errno, make sure that formatMessage gives results
        matching either C{socket.errorTab}, C{ctypes.WinError}, or
        C{win32api.FormatMessage}.
        """
        acceptable = [socket.errorTab[ECONNABORTED]]
        try:
            from ctypes import WinError
            acceptable.append(WinError(ECONNABORTED)[1])
        except ImportError:
            pass
        try:
            from win32api import FormatMessage
            acceptable.append(FormatMessage(ECONNABORTED))
        except ImportError:
            pass

        self.assertIn(formatError(ECONNABORTED), acceptable) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:21,代碼來源:test_strerror.py

示例7: __init__

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import errorTab [as 別名]
def __init__(self, WinError, FormatMessage, errorTab):
        self.winError = WinError
        self.formatMessage = FormatMessage
        self.errorTab = errorTab 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:6,代碼來源:win32.py

示例8: test_errorTab

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import errorTab [as 別名]
def test_errorTab(self):
        """
        L{_ErrorFormatter.formatError} should use C{errorTab} if it is supplied
        and contains the requested error code.
        """
        formatter = _ErrorFormatter(
            None, None, {self.probeErrorCode: self.probeMessage})
        message = formatter.formatError(self.probeErrorCode)
        self.assertEqual(message, self.probeMessage) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:11,代碼來源:test_strerror.py

示例9: test_winError

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import errorTab [as 別名]
def test_winError(self):
        """
        L{_ErrorFormatter.formatError} should return the message argument from
        the exception L{winError} returns, if L{winError} is supplied.
        """
        winCalls = []
        def winError(errorCode):
            winCalls.append(errorCode)
            return _MyWindowsException(errorCode, self.probeMessage)
        formatter = _ErrorFormatter(
            winError,
            lambda error: 'formatMessage: wrong message',
            {self.probeErrorCode: 'errorTab: wrong message'})
        message = formatter.formatError(self.probeErrorCode)
        self.assertEqual(message, self.probeMessage) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:17,代碼來源:test_strerror.py

示例10: test_winError

# 需要導入模塊: import socket [as 別名]
# 或者: from socket import errorTab [as 別名]
def test_winError(self):
        """
        L{_ErrorFormatter.formatError} should return the message argument from
        the exception L{winError} returns, if L{winError} is supplied.
        """
        winCalls = []
        def winError(errorCode):
            winCalls.append(errorCode)
            return (errorCode, self.probeMessage)
        formatter = _ErrorFormatter(
            winError,
            lambda error: 'formatMessage: wrong message',
            {self.probeErrorCode: 'errorTab: wrong message'})
        message = formatter.formatError(self.probeErrorCode)
        self.assertEqual(message, self.probeMessage) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:17,代碼來源:test_strerror.py


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