Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions cryptlex/lexfloatclient/lexfloatclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def __init__(self, name, allowed_uses, total_uses, gross_uses):
self.total_uses = total_uses
self.gross_uses = gross_uses

class ProductVersionFeatureFlag(object):
def __init__(self, name, enabled, data):
self.name = name
self.enabled = enabled
self.data = data

class LexFloatClient:
@staticmethod
Expand Down Expand Up @@ -96,6 +101,66 @@ def SetFloatingClientMetadata(key, value):
if LexFloatStatusCodes.LF_OK != status:
raise LexFloatClientException(status)

@staticmethod
def GetProductVersionName():
"""Gets the product version name.

Raises:
LexFloatClientException

Returns:
str: name of the product version.
"""

buffer_size = 256
buffer = LexFloatClientNative.get_ctype_string_buffer(buffer_size)
status = LexFloatClientNative.GetProductVersionName(buffer,buffer_size)
if status != LexFloatStatusCodes.LF_OK:
raise LexFloatClientException(status)
return LexFloatClientNative.byte_to_string(buffer.value)

@staticmethod
def GetProductVersionDisplayName():
"""Gets the product version display name.

Raises:
LexFloatClientException

Returns:
str: display name of the product version.
"""

buffer_size = 256
buffer = LexFloatClientNative.get_ctype_string_buffer(buffer_size)
status = LexFloatClientNative.GetProductVersionDisplayName(buffer,buffer_size)
if status != LexFloatStatusCodes.LF_OK:
raise LexFloatClientException(status)
return LexFloatClientNative.byte_to_string(buffer.value)

@staticmethod
def GetProductVersionFeatureFlag(name):
"""Gets the product version feature flag.

Args:
name (str): name of the feature flag

Raises:
LexFloatClientException

Returns:
ProductVersionFeatureFlag: product version feature flag
"""
cstring_name = LexFloatClientNative.get_ctype_string(name)
enabled = ctypes.c_uint()
buffer_size = 256
buffer = LexFloatClientNative.get_ctype_string_buffer(buffer_size)
status = LexFloatClientNative.GetProductVersionFeatureFlag(cstring_name, ctypes.byref(enabled), buffer, buffer_size)
if status == LexFloatStatusCodes.LF_OK:
isEnabled = enabled.value > 0
return ProductVersionFeatureFlag(name, isEnabled, LexFloatClientNative.byte_to_string(buffer.value))
else:
raise LexFloatClientException(status)

@staticmethod
def GetHostLicenseMetadata(key):
"""Get the value of the license metadata field associated with the
Expand Down
4 changes: 4 additions & 0 deletions cryptlex/lexfloatclient/lexfloatclient_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def get_error_message(code):
return 'The meter attribute does not exist.'
if code == LexFloatStatusCodes.LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED:
return 'The meter attribute has reached it\'s usage limit.'
if code == LexFloatStatusCodes.LF_E_PRODUCT_VERSION_NOT_LINKED:
return 'No product version is linked with the license.'
if code == LexFloatStatusCodes.LF_E_FEATURE_FLAG_NOT_FOUND:
return 'The product version feature flag does not exist.'
if code == LexFloatStatusCodes.LF_E_IP:
return 'IP address is not allowed.'
if code == LexFloatStatusCodes.LF_E_CLIENT:
Expand Down
12 changes: 12 additions & 0 deletions cryptlex/lexfloatclient/lexfloatclient_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ def byte_to_string(input):
SetFloatingClientMetadata.argtypes = [CSTRTYPE, CSTRTYPE]
SetFloatingClientMetadata.restype = c_int

GetProductVersionName = library.GetProductVersionName
GetProductVersionName.argtypes = [STRTYPE,c_uint32]
GetProductVersionName.restype = c_int

GetProductVersionDisplayName = library.GetProductVersionDisplayName
GetProductVersionDisplayName.argtypes = [STRTYPE,c_uint32]
GetProductVersionDisplayName.restype = c_int

GetProductVersionFeatureFlag = library.GetProductVersionFeatureFlag
GetProductVersionFeatureFlag.argtypes = [CSTRTYPE, POINTER(c_uint32), STRTYPE, c_uint32]
GetProductVersionFeatureFlag.restype = c_int

GetHostLicenseMetadata = library.GetHostLicenseMetadata
GetHostLicenseMetadata.argtypes = [CSTRTYPE, STRTYPE, c_uint32]
GetHostLicenseMetadata.restype = c_int
Expand Down
4 changes: 4 additions & 0 deletions cryptlex/lexfloatclient/lexfloatstatus_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class LexFloatStatusCodes:

LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED = 56

LF_E_PRODUCT_VERSION_NOT_LINKED = 57

LF_E_FEATURE_FLAG_NOT_FOUND = 58

LF_E_IP = 60

LF_E_CLIENT = 70
Expand Down