def getTokenInfo(self, slot):
        """
        C_GetTokenInfo

        :param slot: slot number returned by :func:`getSlotList`
        :type slot: integer
        :return: a :class:`CK_TOKEN_INFO` object
        """
        tokeninfo = PyKCS11.LowLevel.CK_TOKEN_INFO()
        rv = self.lib.C_GetTokenInfo(slot, tokeninfo)
        if rv != CKR_OK:
            raise PyKCS11Error(rv)

        t = CK_TOKEN_INFO()
        t.label = tokeninfo.GetLabel()
        t.manufacturerID = tokeninfo.GetManufacturerID()
        t.model = tokeninfo.GetModel()
        t.serialNumber = tokeninfo.GetSerialNumber()
        t.flags = tokeninfo.flags
        t.ulMaxSessionCount = tokeninfo.ulMaxSessionCount
        if t.ulMaxSessionCount == CK_UNAVAILABLE_INFORMATION:
            t.ulMaxSessionCount = -1
        t.ulSessionCount = tokeninfo.ulSessionCount
        if t.ulSessionCount == CK_UNAVAILABLE_INFORMATION:
            t.ulSessionCount = -1
        t.ulMaxRwSessionCount = tokeninfo.ulMaxRwSessionCount
        if t.ulMaxRwSessionCount == CK_UNAVAILABLE_INFORMATION:
            t.ulMaxRwSessionCount = -1
        t.ulRwSessionCount = tokeninfo.ulRwSessionCount
        if t.ulRwSessionCount == CK_UNAVAILABLE_INFORMATION:
            t.ulRwSessionCount = -1
        t.ulMaxPinLen = tokeninfo.ulMaxPinLen
        t.ulMinPinLen = tokeninfo.ulMinPinLen
        t.ulTotalPublicMemory = tokeninfo.ulTotalPublicMemory

        if t.ulTotalPublicMemory == CK_UNAVAILABLE_INFORMATION:
            t.ulTotalPublicMemory = -1
        t.ulFreePublicMemory = tokeninfo.ulFreePublicMemory
        if t.ulFreePublicMemory == CK_UNAVAILABLE_INFORMATION:
            t.ulFreePublicMemory = -1
        t.ulTotalPrivateMemory = tokeninfo.ulTotalPrivateMemory
        if t.ulTotalPrivateMemory == CK_UNAVAILABLE_INFORMATION:
            t.ulTotalPrivateMemory = -1
        t.ulFreePrivateMemory = tokeninfo.ulFreePrivateMemory
        if t.ulFreePrivateMemory == CK_UNAVAILABLE_INFORMATION:
            t.ulFreePrivateMemory = -1
        t.hardwareVersion = (tokeninfo.hardwareVersion.major,
                             tokeninfo.hardwareVersion.minor)
        t.firmwareVersion = (tokeninfo.firmwareVersion.major,
                             tokeninfo.firmwareVersion.minor)
        t.utcTime = tokeninfo.GetUtcTime().replace('\000', ' ')

        return t
def getTokenInfo(self, slot):
        """
        C_GetTokenInfo

        :param slot: slot number returned by :func:`getSlotList`
        :type slot: integer
        :return: a :class:`CK_TOKEN_INFO` object
        """
        tokeninfo = PyKCS11.LowLevel.CK_TOKEN_INFO()
        rv = self.lib.C_GetTokenInfo(slot, tokeninfo)
        if rv != CKR_OK:
            raise PyKCS11Error(rv)

        t = CK_TOKEN_INFO()
        t.label = tokeninfo.GetLabel()
        t.manufacturerID = tokeninfo.GetManufacturerID()
        t.model = tokeninfo.GetModel()
        t.serialNumber = tokeninfo.GetSerialNumber()
        t.flags = tokeninfo.flags
        t.ulMaxSessionCount = tokeninfo.ulMaxSessionCount
        if t.ulMaxSessionCount == CK_UNAVAILABLE_INFORMATION:
            t.ulMaxSessionCount = -1
        t.ulSessionCount = tokeninfo.ulSessionCount
        if t.ulSessionCount == CK_UNAVAILABLE_INFORMATION:
            t.ulSessionCount = -1
        t.ulMaxRwSessionCount = tokeninfo.ulMaxRwSessionCount
        if t.ulMaxRwSessionCount == CK_UNAVAILABLE_INFORMATION:
            t.ulMaxRwSessionCount = -1
        t.ulRwSessionCount = tokeninfo.ulRwSessionCount
        if t.ulRwSessionCount == CK_UNAVAILABLE_INFORMATION:
            t.ulRwSessionCount = -1
        t.ulMaxPinLen = tokeninfo.ulMaxPinLen
        t.ulMinPinLen = tokeninfo.ulMinPinLen
        t.ulTotalPublicMemory = tokeninfo.ulTotalPublicMemory

        if t.ulTotalPublicMemory == CK_UNAVAILABLE_INFORMATION:
            t.ulTotalPublicMemory = -1
        t.ulFreePublicMemory = tokeninfo.ulFreePublicMemory
        if t.ulFreePublicMemory == CK_UNAVAILABLE_INFORMATION:
            t.ulFreePublicMemory = -1
        t.ulTotalPrivateMemory = tokeninfo.ulTotalPrivateMemory
        if t.ulTotalPrivateMemory == CK_UNAVAILABLE_INFORMATION:
            t.ulTotalPrivateMemory = -1
        t.ulFreePrivateMemory = tokeninfo.ulFreePrivateMemory
        if t.ulFreePrivateMemory == CK_UNAVAILABLE_INFORMATION:
            t.ulFreePrivateMemory = -1
        t.hardwareVersion = (tokeninfo.hardwareVersion.major,
                             tokeninfo.hardwareVersion.minor)
        t.firmwareVersion = (tokeninfo.firmwareVersion.major,
                             tokeninfo.firmwareVersion.minor)
        t.utcTime = tokeninfo.GetUtcTime().replace('\000', ' ')

        return t
def getTokenInfo ( self , slot ) : tokeninfo = PyKCS11 . LowLevel . CK_TOKEN_INFO ( ) rv = self . lib . C_GetTokenInfo ( slot , tokeninfo ) if rv != CKR_OK : raise PyKCS11Error ( rv ) t = CK_TOKEN_INFO ( ) t . label = tokeninfo . GetLabel ( ) t . manufacturerID = tokeninfo . GetManufacturerID ( ) t . model = tokeninfo . GetModel ( ) t . serialNumber = tokeninfo . GetSerialNumber ( ) t . flags = tokeninfo . flags t . ulMaxSessionCount = tokeninfo . ulMaxSessionCount if t . ulMaxSessionCount == CK_UNAVAILABLE_INFORMATION : t . ulMaxSessionCount = - 1 t . ulSessionCount = tokeninfo . ulSessionCount if t . ulSessionCount == CK_UNAVAILABLE_INFORMATION : t . ulSessionCount = - 1 t . ulMaxRwSessionCount = tokeninfo . ulMaxRwSessionCount if t . ulMaxRwSessionCount == CK_UNAVAILABLE_INFORMATION : t . ulMaxRwSessionCount = - 1 t . ulRwSessionCount = tokeninfo . ulRwSessionCount if t . ulRwSessionCount == CK_UNAVAILABLE_INFORMATION : t . ulRwSessionCount = - 1 t . ulMaxPinLen = tokeninfo . ulMaxPinLen t . ulMinPinLen = tokeninfo . ulMinPinLen t . ulTotalPublicMemory = tokeninfo . ulTotalPublicMemory if t . ulTotalPublicMemory == CK_UNAVAILABLE_INFORMATION : t . ulTotalPublicMemory = - 1 t . ulFreePublicMemory = tokeninfo . ulFreePublicMemory if t . ulFreePublicMemory == CK_UNAVAILABLE_INFORMATION : t . ulFreePublicMemory = - 1 t . ulTotalPrivateMemory = tokeninfo . ulTotalPrivateMemory if t . ulTotalPrivateMemory == CK_UNAVAILABLE_INFORMATION : t . ulTotalPrivateMemory = - 1 t . ulFreePrivateMemory = tokeninfo . ulFreePrivateMemory if t . ulFreePrivateMemory == CK_UNAVAILABLE_INFORMATION : t . ulFreePrivateMemory = - 1 t . hardwareVersion = ( tokeninfo . hardwareVersion . major , tokeninfo . hardwareVersion . minor ) t . firmwareVersion = ( tokeninfo . firmwareVersion . major , tokeninfo . firmwareVersion . minor ) t . utcTime = tokeninfo . GetUtcTime ( ) . replace ( '\000' , ' ' ) return t
C_GetTokenInfo

        :param slot: slot number returned by :func:`getSlotList`
        :type slot: integer
        :return: a :class:`CK_TOKEN_INFO` object
C_GetTokenInfo