示例#1
0
    def CheckForReleaseUpdate(platform, version, channel, release_callback):
        """Checks whether a new release is available for the product.

        This function should only be used if you manage your releases through
        Cryptlex release management API.

        Args:
                platform (str): release platform e.g. windows, macos, linux
                version (str): current release version
                channel (str): release channel e.g. stable
                release_callback (Callable[int]]): callback function

        Raises:
                LexActivatorException
        """
        cstring_platform = LexActivatorNative.get_ctype_string(platform)
        cstring_version = LexActivatorNative.get_ctype_string(version)
        cstring_channel = LexActivatorNative.get_ctype_string(channel)

        release_callback_fn = LexActivatorNative.CallbackType(release_callback)
        callback_list.append(release_callback_fn)
        status = LexActivatorNative.CheckForReleaseUpdate(
            cstring_platform, cstring_version, cstring_channel, release_callback_fn)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#2
0
    def GenerateOfflineDeactivationRequest(file_path):
        """Generates the offline deactivation request needed for deactivation of the
        license in the dashboard and deactivates the license locally.

        A valid offline deactivation file confirms that the license has been
        successfully deactivated on the user's machine.

        Args:
                file_path (str): path of the file for the offline deactivation request

        Raises:
                LexActivatorException

        Returns:
                int: LA_OK, LA_FAIL
        """
        cstring_file_path = LexActivatorNative.get_ctype_string(file_path)
        status = LexActivatorNative.GenerateOfflineDeactivationRequest(
            cstring_file_path)
        if LexStatusCodes.LA_OK == status:
            return LexStatusCodes.LA_OK
        elif LexStatusCodes.LA_FAIL == status:
            return LexStatusCodes.LA_FAIL
        else:
            raise LexActivatorException(status)
示例#3
0
    def SetTrialActivationMetadata(key, value):
        """Sets the trial activation metadata.

        The metadata appears along with the trial activation details of the product
        in dashboard.

        Args:
                key (str): string of maximum length 256 characters with utf-8 encoding
                value (str): string of maximum length 256 characters with utf-8 encoding

        Raises:
                LexActivatorException
        """
        cstring_key = LexActivatorNative.get_ctype_string(key)
        cstring_value = LexActivatorNative.get_ctype_string(value)
        status = LexActivatorNative.SetTrialActivationMetadata(
            cstring_key, cstring_value)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#4
0
    def SetLicenseUserCredential(email, password):
        """Sets the license user email and password for authentication.

        This function must be called before ActivateLicense() or IsLicenseGenuine()
        function if requireAuthentication property of the license is set to true.

        Args:
                email (str): user email address
                password (str): user password

        Raises:
                LexActivatorException
        """
        cstring_email = LexActivatorNative.get_ctype_string(email)
        cstring_password = LexActivatorNative.get_ctype_string(password)

        status = LexActivatorNative.SetLicenseUserCredential(
            cstring_email, cstring_password)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#5
0
    def SetLicenseKey(license_key):
        """Sets the license key required to activate the license.

        Args:
                license_key (str): a valid license key

        Raises:
                LexActivatorException
        """
        cstring_license_key = LexActivatorNative.get_ctype_string(license_key)
        status = LexActivatorNative.SetLicenseKey(cstring_license_key)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#6
0
    def SetCryptlexHost(host):
        """In case you are running Cryptlex on-premise, you can set the host for your
        on-premise server.

        Args:
                host (str): the address of the Cryptlex on-premise server

        Raises:
                LexActivatorException
        """
        cstring_host = LexActivatorNative.get_ctype_string(host)
        status = LexActivatorNative.SetCryptlexHost(cstring_host)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#7
0
    def ResetActivationMeterAttributeUses(name):
        """Resets the meter attribute uses of the activation.

        Args:
                name (str): name of the meter attribute

        Raises:
                LexActivatorException
        """
        cstring_name = LexActivatorNative.get_ctype_string(name)
        status = LexActivatorNative.ResetActivationMeterAttributeUses(
            cstring_name)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#8
0
    def GenerateOfflineTrialActivationRequest(file_path):
        """Generates the offline trial activation request needed for generating offline
        trial activation response in the dashboard.

        Args:
                file_path (str): path of the file for the offline request

        Raises:
                LexActivatorException
        """
        cstring_file_path = LexActivatorNative.get_ctype_string(file_path)
        status = LexActivatorNative.GenerateOfflineTrialActivationRequest(
            cstring_file_path)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#9
0
    def DecrementActivationMeterAttributeUses(name, decrement):
        """Decrements the meter attribute uses of the activation.

        Args:
                name (str): name of the meter attribute
                decrement (int): the decrement value

        Raises:
                LexActivatorException
        """
        cstring_name = LexActivatorNative.get_ctype_string(name)
        status = LexActivatorNative.DecrementActivationMeterAttributeUses(
            cstring_name, decrement)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#10
0
    def SetProductFile(file_path):
        """Sets the absolute path of the Product.dat file.

        This function must be called on every start of your program before any other
        functions are called.

        Args:
                file_path (str): absolute path of the product file (Product.dat)

        Raises:
                LexActivatorException
        """
        cstring = LexActivatorNative.get_ctype_string(file_path)
        status = LexActivatorNative.SetProductFile(cstring)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#11
0
    def SetAppVersion(app_version):
        """Sets the current app version of your application.

        The app version appears along with the activation details in dashboard. It is
        also used to generate app analytics.

        Args:
                app_version (str): string of maximum length 256 characters with utf-8 encoding.

        Raises:
                LexActivatorException
        """
        cstring_app_version = LexActivatorNative.get_ctype_string(app_version)

        status = LexActivatorNative.SetAppVersion(cstring_app_version)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#12
0
    def SetOfflineActivationRequestMeterAttributeUses(name, uses):
        """Sets the meter attribute uses for the offline activation request.

        This function should only be called before GenerateOfflineActivationRequest()
        function to set the meter attributes in case of offline activation.

        Args:
                name (str): name of the meter attribute
                uses (int): the uses value

        Raises:
                LexActivatorException
        """
        cstring_name = LexActivatorNative.get_ctype_string(name)
        status = LexActivatorNative.SetOfflineActivationRequestMeterAttributeUses(
            cstring_name, uses)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#13
0
    def SetProductId(product_id, flags):
        """Sets the product id of your application.

        This function must be called on every start of your program before any other
        functions are called, with the exception of SetProductFile() or
        SetProductData() function.

        Args:
                product_id (str): the unique product id of your application as mentioned on the product page in the dashboard
                flags (str): depending upon whether your application requires admin/root permissions to run or not, this parameter can have one of the following values: LA_SYSTEM, LA_USER, LA_IN_MEMORY

        Raises:
                LexActivatorException
        """
        cstring_product_id = LexActivatorNative.get_ctype_string(product_id)
        status = LexActivatorNative.SetProductId(cstring_product_id, flags)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#14
0
    def GetTrialActivationMetadata(key):
        """Gets the trial activation metadata.

        Args:
                key (str): metadata key to retrieve the value

        Raises:
                LexActivatorException

        Returns:
                str: value of metadata for the key
        """
        cstring_key = LexActivatorNative.get_ctype_string(key)
        buffer_size = 256
        buffer = LexActivatorNative.get_ctype_string_buffer(buffer_size)
        status = LexActivatorNative.GetTrialActivationMetadata(
            cstring_key, buffer, buffer_size)
        if status != LexStatusCodes.LA_OK:
            raise LexActivatorException(status)
        return LexActivatorNative.byte_to_string(buffer.value)
示例#15
0
    def GetActivationMeterAttributeUses(name):
        """Gets the meter attribute uses consumed by the activation.

        Args:
                name (str): name of the meter attribute

        Raises:
                LexActivatorException

        Returns:
                int: value of meter attribute uses by the activation
        """
        cstring_name = LexActivatorNative.get_ctype_string(name)
        uses = ctypes.c_uint()
        status = LexActivatorNative.GetActivationMeterAttributeUses(
            cstring_name, ctypes.byref(uses))
        if status == LexStatusCodes.LA_OK:
            return uses.value
        else:
            raise LexActivatorException(status)
示例#16
0
    def SetProductData(product_data):
        """Embeds the Product.dat file in the application.

        It can be used instead of SetProductFile() in case you want to embed the
        Product.dat file in your application.

        This function must be called on every start of your program before any other
        functions are called.

        Args:
                product_data (str): content of the Product.dat file

        Raises:
                LexActivatorException
        """
        cstring_product_data = LexActivatorNative.get_ctype_string(
            product_data)
        status = LexActivatorNative.SetProductData(cstring_product_data)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#17
0
    def SetCustomDeviceFingerprint(fingerprint):
        """In case you don't want to use the LexActivator's advanced
        device fingerprinting algorithm, this function can be used to set a custom
        device fingerprint.

        If you decide to use your own custom device fingerprint then this function must be
        called on every start of your program immediately after calling SetProductFile()
        or SetProductData() function.

        The license fingerprint matching strategy is ignored if this function is used.

        Args:
                fingerprint (str): string of minimum length 64 characters and maximum length 256 characters

        Raises:
                LexActivatorException
        """
        cstring_fingerprint = LexActivatorNative.get_ctype_string(fingerprint)
        status = LexActivatorNative.SetProductData(cstring_fingerprint)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
    def SetDataDirectory(directory_path):
        """In case you want to change the default directory used by LexActivator to
        store the activation data on Linux and macOS, this function can be used to
        set a different directory.

        If you decide to use this function, then it must be called on every start of
        your program before calling SetProductFile() or SetProductData() function.

        Please ensure that the directory exists and your app has read and write
        permissions in the directory.

        Args:
                directory_path (str): absolute path of the directory.

        Raises:
                LexActivatorException
        """
        cstring = LexActivatorNative.get_ctype_string(directory_path)
        status = LexActivatorNative.SetDataDirectory(cstring)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#19
0
    def SetNetworkProxy(proxy):
        """Sets the network proxy to be used when contacting CryptLex servers.

        The proxy format should be: [protocol://][username:password@]machine[:port]

        Note: 
                Proxy settings of the computer are automatically detected. So,
                in most of the cases you don't need to care whether your user is behind a
                proxy server or not.

        Args:
                proxy (str): proxy having correct proxy format

        Raises:
                LexActivatorException
        """
        cstring_proxy = LexActivatorNative.get_ctype_string(proxy)

        status = LexActivatorNative.SetNetworkProxy(cstring_proxy)
        if LexStatusCodes.LA_OK != status:
            raise LexActivatorException(status)
示例#20
0
    def GetLicenseMeterAttribute(name):
        """Gets the license meter attribute allowed uses and total uses.

        Args:
                name (str): name of the meter attribute

        Raises:
                LexActivatorException

        Returns:
                LicenseMeterAttribute: values of meter attribute allowed and total uses
        """
        cstring_name = LexActivatorNative.get_ctype_string(name)
        allowed_uses = ctypes.c_uint()
        total_uses = ctypes.c_uint()
        status = LexActivatorNative.GetLicenseMeterAttribute(
            cstring_name, ctypes.byref(allowed_uses), ctypes.byref(total_uses))
        if status == LexStatusCodes.LA_OK:
            return LicenseMeterAttribute(name, allowed_uses.value, total_uses.value)
        else:
            raise LexActivatorException(status)
示例#21
0
    def ActivateTrialOffline(file_path):
        """Activates the trial using the offline activation response file.

        Args:
                file_path (str): path of the offline activation response file

        Raises:
                LexActivatorException

        Returns:
                int: LA_OK, LA_TRIAL_EXPIRED, LA_FAIL
        """
        cstring_file_path = LexActivatorNative.get_ctype_string(file_path)
        status = LexActivatorNative.ActivateTrialOffline(cstring_file_path)
        if LexStatusCodes.LA_OK == status:
            return LexStatusCodes.LA_OK
        elif LexStatusCodes.LA_TRIAL_EXPIRED == status:
            return LexStatusCodes.LA_TRIAL_EXPIRED
        elif LexStatusCodes.LA_FAIL == status:
            return LexStatusCodes.LA_FAIL
        else:
            raise LexActivatorException(status)
    def GetProductVersionFeatureFlag(name):
        """Gets the product version feature flag.

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

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