Skip to content

Commit 44a5f81

Browse files
committed
Fix an error in Deactivate and CreateTrial Key (for Python 2 & 3)
1 parent ceeee0c commit 44a5f81

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

cryptolens_python2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return
185185
More docs: https://app.cryptolens.io/docs/api/v3/Activate
186186
"""
187187

188-
response = Response("","","","")
188+
response = Response("","",0,"")
189189

190190
try:
191191
response = Response.from_string(HelperMethods.send_request("key/activate", {"token":token,\
@@ -235,7 +235,7 @@ def create_trial_key(token, product_id, machine_code):
235235

236236
jobj = json.loads(response)
237237

238-
if jobj == None or jobj["result"] == "1":
238+
if jobj == None or not("result" in jobj) or jobj["result"] == 1:
239239
if jobj != None:
240240
return (None, jobj["message"])
241241
else:
@@ -269,7 +269,7 @@ def deactivate(token, product_id, key, machine_code, floating = False):
269269

270270
jobj = json.loads(response)
271271

272-
if jobj == None or jobj["result"] == "1":
272+
if jobj == None or not("result" in jobj) or jobj["result"] == 1:
273273
if jobj != None:
274274
return (False, jobj["message"])
275275
else:
@@ -461,7 +461,7 @@ def from_string(responseString):
461461

462462
licenseKey = ""
463463
signature = ""
464-
result = ""
464+
result = 0
465465
message = ""
466466

467467
if "licenseKey" in obj:

licensing/methods.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return
3131
More docs: https://app.cryptolens.io/docs/api/v3/Activate
3232
"""
3333

34-
response = Response("","","","")
34+
response = Response("","",0,"")
3535

3636
try:
3737
response = Response.from_string(HelperMethods.send_request("key/activate", {"token":token,\
@@ -81,7 +81,7 @@ def create_trial_key(token, product_id, machine_code):
8181

8282
jobj = json.loads(response)
8383

84-
if jobj == None or str(jobj["result"]) == "1":
84+
if jobj == None or not("result" in jobj) or jobj["result"] == 1:
8585
if jobj != None:
8686
return (None, jobj["message"])
8787
else:
@@ -112,7 +112,7 @@ def deactivate(token, product_id, key, machine_code, floating = False):
112112

113113
jobj = json.loads(response)
114114

115-
if jobj == None or jobj["result"] == "1":
115+
if jobj == None or not("result" in jobj) or jobj["result"] == 1:
116116
if jobj != None:
117117
return (False, jobj["message"])
118118
else:

licensing/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def from_string(responseString):
145145

146146
licenseKey = ""
147147
signature = ""
148-
result = ""
148+
result = 0
149149
message = ""
150150

151151
if "licenseKey" in obj:

test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242

4343
print(Helpers.GetMachineCode())
4444

45-
res = Key.create_trial_key("WyIzODQ0IiwiempTRWs4SnBKTTArYUh3WkwyZ0VwQkVyeTlUVkRWK2ZTOS8wcTBmaCJd", 3941, Helpers.GetMachineCode())
45+
#res = Key.create_trial_key("WyIzODQ0IiwiempTRWs4SnBKTTArYUh3WkwyZ0VwQkVyeTlUVkRWK2ZTOS8wcTBmaCJd", 3941, Helpers.GetMachineCode())

0 commit comments

Comments
 (0)