activate key with python check_and_save_pkey

Hello,

I'm using the turboactivate official python bindings, trying to add product key and using check_and_save_pkey.

I've setup the TurboActivate.dat, the proper lib path, and product version guid, and generated a key license.

I've notice that unlike the C API, the check_and_save_pkey does not return any value.

So to check that the call to check_and_save_pkey(pkey), was successful after performing the check i've performed a call to is_activated() which returns False always.

I've also noticed that the error handling via exceptions is not properly implemented in the bindings, as it is not checking the result status and sending the right exception.

Most of the methods do not use validate_result(ret) as is_activated does, so how can those other methods issue the right exception?

Am I doing using the python libs wrongly?

Thanks,Best regards

Latest version with a full example (including how to use CheckAndSavePKey) is here: https://github.com/wyattoday/python-turboactivate

Hi Wayatt, I missed to login on this post.

I did check the code and have the latest, as you mentioned in an earlier post.I did check the example, and though it seems similar to the C example, the error handling is not being done properly (via exceptions), because the result from the dynamic lib is not being taken into account to generate exceptions.

If you're using our code, it actually does raise an error one an error (see 'validate_result' in c_wrapper.py). Also, see try/except block in example.py.

So what I mean is specifically is, in the turboactivate/__init__.py the method

def check_and_save_pkey(self, product_key):        """Checks and saves the product key."""        self._lib.TA_CheckAndSavePKey(self._handle, wstr(product_key), self._mode)

Performs a call to the dynamic library directly, and does not return anything, nor as it seems, raises any exceptions.

I would expect the same behaviour of the C API, described in the TurboActivate.h code comments, see below.

/*   Checks and saves the product key.




   Note: If you pass in the TA_SYSTEM flag and you don't have "admin" or "elevated"   permission then the call will fail.


   If you call this function once in the past with the flag TA_SYSTEM and the calling   process was an admin process then subsequent calls with the TA_SYSTEM flag will   succeed even if the calling process is *not* admin/elevated.


   If you want to take advantage of this behavior from an admin process   (e.g. an installer) but the user hasn't entered a product key then you can   call this function with a null string:


            TA_CheckAndSavePKey(yourHandle, 0, TA_SYSTEM);


   This will set everything up so that subsequent calls with the TA_SYSTEM flag will   succeed even if from non-admin processes.


   Note: Calling TA_CheckAndSavePKey(yourHandle, 0, TA_SYSTEM) will return TA_FAIL         if the system files were correctly setup. It will return TA_E_PERMISSION if         the system files were not setup due to lack of permissions. The reason it		 returns TA_FAIL instead of TA_OK is because passing in a "NULL" product key		 is not valid.




   Returns: TA_OK on success. Handle all other return codes as failures.


   Possible return codes: TA_OK, TA_FAIL, TA_E_PERMISSION, TA_E_INVALID_FLAGS                          TA_E_ALREADY_ACTIVATED*/TURBOACTIVATE_API HRESULT TA_CC TA_CheckAndSavePKey(uint32_t handle, STRCTYPE productKey, uint32_t flags);

Namely I would expect to see the following implementation:

    def check_and_save_pkey(self, product_key):        """Checks and saves the product key."""        _TA_CheckAndSavePKey = self._lib.TA_CheckAndSavePKey        _TA_CheckAndSavePKey.restype = c_int32        ret = self._lib.TA_CheckAndSavePKey(self._handle, wstr(product_key), self._mode)        validate_result(ret)