Python pythoncom 模块,GetScodeString() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用pythoncom.GetScodeString()

项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def __init__(self, description = None, scode = None,
                 source = None, helpfile = None, helpContext = None,
                 desc = None, hresult = None):
        """Initialize an exception
        **Params**

        description -- A string description for the exception.
        scode -- An integer scode to be returned to the server, if necessary.
        The pythoncom framework defaults this to be DISP_E_EXCEPTION if not specified otherwise.
        source -- A string which identifies the source of the error.
        helpfile -- A string which points to a help file which contains details on the error.
        helpContext -- An integer context in the help file.
        desc -- A short-cut for description.
        hresult -- A short-cut for scode.
        """

        # convert a WIN32 error into an HRESULT
        scode = scode or hresult
        if scode and scode != 1: # We dont want S_FALSE mapped!
            if scode >= -32768 and scode < 32768:
                # this is HRESULT_FROM_WIN32()
                scode = -2147024896 | (scode & 0x0000FFFF)
        self.scode = scode

        self.description = description or desc
        if scode==1 and not self.description:
            self.description = "S_FALSE"
        elif scode and not self.description:
            self.description = pythoncom.GetScodeString(scode)

        self.source = source
        self.helpfile = helpfile
        self.helpcontext = helpContext

        # todo - fill in the exception value
        pythoncom.com_error.__init__(self, scode, self.description, None, -1)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def __init__(self, description = None, scode = None,
                 source = None, helpfile = None, helpContext = None,
                 desc = None, hresult = None):
        """Initialize an exception
        **Params**

        description -- A string description for the exception.
        scode -- An integer scode to be returned to the server, if necessary.
        The pythoncom framework defaults this to be DISP_E_EXCEPTION if not specified otherwise.
        source -- A string which identifies the source of the error.
        helpfile -- A string which points to a help file which contains details on the error.
        helpContext -- An integer context in the help file.
        desc -- A short-cut for description.
        hresult -- A short-cut for scode.
        """

        # convert a WIN32 error into an HRESULT
        scode = scode or hresult
        if scode and scode != 1: # We dont want S_FALSE mapped!
            if scode >= -32768 and scode < 32768:
                # this is HRESULT_FROM_WIN32()
                scode = -2147024896 | (scode & 0x0000FFFF)
        self.scode = scode

        self.description = description or desc
        if scode==1 and not self.description:
            self.description = "S_FALSE"
        elif scode and not self.description:
            self.description = pythoncom.GetScodeString(scode)

        self.source = source
        self.helpfile = helpfile
        self.helpcontext = helpContext

        # todo - fill in the exception value
        pythoncom.com_error.__init__(self, scode, self.description, None, -1)
项目:opc-rest-api    作者:matzpersson    | 项目源码 | 文件源码
def _get_error_str(self, err):
      """Return the error string for a OPC or COM error code"""

      hr, msg, exc, arg = err

      if exc == None:
         error_str = str(msg)
      else:
         scode = exc[5]

         try:
            opc_err_str = unicode(self._opc.GetErrorString(scode)).strip('\r\n')
         except:
            opc_err_str = None

         try:
            com_err_str = unicode(pythoncom.GetScodeString(scode)).strip('\r\n')
         except:
            com_err_str = None

         # OPC error codes and COM error codes are overlapping concepts,
         # so we combine them together into a single error message.

         if opc_err_str == None and com_err_str == None:
            error_str = str(scode)
         elif opc_err_str == com_err_str:
            error_str = opc_err_str
         elif opc_err_str == None:
            error_str = com_err_str
         elif com_err_str == None:
            error_str = opc_err_str
         else:
            error_str = '%s (%s)' % (opc_err_str, com_err_str)

      return error_str
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def GetScodeString(hr):
    if not mapiErrorTable:
        for name, value in mapi.__dict__.iteritems():
            if name[:7] in ['MAPI_E_', 'MAPI_W_']:
                mapiErrorTable[value] = name
    return mapiErrorTable.get(hr, pythoncom.GetScodeString(hr))
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def __init__(self, description = None, scode = None,
                 source = None, helpfile = None, helpContext = None,
                 desc = None, hresult = None):
        """Initialize an exception
        **Params**

        description -- A string description for the exception.
        scode -- An integer scode to be returned to the server, if necessary.
        The pythoncom framework defaults this to be DISP_E_EXCEPTION if not specified otherwise.
        source -- A string which identifies the source of the error.
        helpfile -- A string which points to a help file which contains details on the error.
        helpContext -- An integer context in the help file.
        desc -- A short-cut for description.
        hresult -- A short-cut for scode.
        """

        # convert a WIN32 error into an HRESULT
        scode = scode or hresult
        if scode and scode != 1: # We dont want S_FALSE mapped!
            if scode >= -32768 and scode < 32768:
                # this is HRESULT_FROM_WIN32()
                scode = -2147024896 | (scode & 0x0000FFFF)
        self.scode = scode

        self.description = description or desc
        if scode==1 and not self.description:
            self.description = "S_FALSE"
        elif scode and not self.description:
            self.description = pythoncom.GetScodeString(scode)

        self.source = source
        self.helpfile = helpfile
        self.helpcontext = helpContext

        # todo - fill in the exception value
        pythoncom.com_error.__init__(self, scode, self.description, None, -1)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def GetScodeString(hr):
    if not mapiErrorTable:
        for name, value in mapi.__dict__.items():
            if name[:7] in ['MAPI_E_', 'MAPI_W_']:
                mapiErrorTable[value] = name
    return mapiErrorTable.get(hr, pythoncom.GetScodeString(hr))
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def __init__(self, description = None, scode = None,
                 source = None, helpfile = None, helpContext = None,
                 desc = None, hresult = None):
        """Initialize an exception
        **Params**

        description -- A string description for the exception.
        scode -- An integer scode to be returned to the server, if necessary.
        The pythoncom framework defaults this to be DISP_E_EXCEPTION if not specified otherwise.
        source -- A string which identifies the source of the error.
        helpfile -- A string which points to a help file which contains details on the error.
        helpContext -- An integer context in the help file.
        desc -- A short-cut for description.
        hresult -- A short-cut for scode.
        """

        # convert a WIN32 error into an HRESULT
        scode = scode or hresult
        if scode and scode != 1: # We dont want S_FALSE mapped!
            if scode >= -32768 and scode < 32768:
                # this is HRESULT_FROM_WIN32()
                scode = -2147024896 | (scode & 0x0000FFFF)
        self.scode = scode

        self.description = description or desc
        if scode==1 and not self.description:
            self.description = "S_FALSE"
        elif scode and not self.description:
            self.description = pythoncom.GetScodeString(scode)

        self.source = source
        self.helpfile = helpfile
        self.helpcontext = helpContext

        # todo - fill in the exception value
        pythoncom.com_error.__init__(self, scode, self.description, None, -1)