Python socket.errorTab() Examples
The following are 29
code examples of socket.errorTab().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
socket
, or try the search function
.
Example #1
Source File: test_strerror.py From learn_python3_spider with MIT License | 6 votes |
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)
Example #2
Source File: win32util.py From PokemonGo-DesktopMap with MIT License | 6 votes |
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)
Example #3
Source File: win32util.py From PokemonGo-DesktopMap with MIT License | 6 votes |
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)
Example #4
Source File: win32util.py From PokemonGo-DesktopMap with MIT License | 6 votes |
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)
Example #5
Source File: test_strerror.py From python-for-android with Apache License 2.0 | 6 votes |
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)
Example #6
Source File: win32.py From python-for-android with Apache License 2.0 | 6 votes |
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)
Example #7
Source File: win32.py From python-for-android with Apache License 2.0 | 6 votes |
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)
Example #8
Source File: win32util.py From PhonePi_SampleServer with MIT License | 6 votes |
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)
Example #9
Source File: win32util.py From PhonePi_SampleServer with MIT License | 6 votes |
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)
Example #10
Source File: win32.py From learn_python3_spider with MIT License | 6 votes |
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)
Example #11
Source File: win32.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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)
Example #12
Source File: win32.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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)
Example #13
Source File: win32util.py From satori with Apache License 2.0 | 6 votes |
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)
Example #14
Source File: win32util.py From satori with Apache License 2.0 | 6 votes |
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)
Example #15
Source File: win32.py From learn_python3_spider with MIT License | 6 votes |
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)
Example #16
Source File: test_strerror.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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)
Example #17
Source File: win32util.py From satori with Apache License 2.0 | 5 votes |
def __init__(self, WinError, FormatMessage, errorTab): self.winError = WinError self.formatMessage = FormatMessage self.errorTab = errorTab
Example #18
Source File: win32util.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def __init__(self, WinError, FormatMessage, errorTab): self.winError = WinError self.formatMessage = FormatMessage self.errorTab = errorTab
Example #19
Source File: test_strerror.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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)
Example #20
Source File: win32util.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def __init__(self, WinError, FormatMessage, errorTab): self.winError = WinError self.formatMessage = FormatMessage self.errorTab = errorTab
Example #21
Source File: test_strerror.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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)
Example #22
Source File: test_strerror.py From python-for-android with Apache License 2.0 | 5 votes |
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)
Example #23
Source File: test_strerror.py From python-for-android with Apache License 2.0 | 5 votes |
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)
Example #24
Source File: win32.py From python-for-android with Apache License 2.0 | 5 votes |
def __init__(self, WinError, FormatMessage, errorTab): self.winError = WinError self.formatMessage = FormatMessage self.errorTab = errorTab
Example #25
Source File: win32util.py From PhonePi_SampleServer with MIT License | 5 votes |
def __init__(self, WinError, FormatMessage, errorTab): self.winError = WinError self.formatMessage = FormatMessage self.errorTab = errorTab
Example #26
Source File: win32.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def __init__(self, WinError, FormatMessage, errorTab): self.winError = WinError self.formatMessage = FormatMessage self.errorTab = errorTab
Example #27
Source File: test_strerror.py From learn_python3_spider with MIT License | 5 votes |
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)
Example #28
Source File: test_strerror.py From learn_python3_spider with MIT License | 5 votes |
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)
Example #29
Source File: win32.py From learn_python3_spider with MIT License | 5 votes |
def __init__(self, WinError, FormatMessage, errorTab): self.winError = WinError self.formatMessage = FormatMessage self.errorTab = errorTab