Skip to content

Commit 2e6720b

Browse files
committed
Fix error handling and update version number
1 parent 168723d commit 2e6720b

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

licensing/methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return
4747

4848
pubkey = RSAPublicKey.from_string(rsa_pub_key)
4949

50-
if response.result == "1":
50+
if response.result == 1:
5151
return (None, response.message)
5252
else:
5353
try:

licensing/models.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,27 @@ def __init__(self, license_key, signature, result, message):
138138

139139
def from_string(responseString):
140140
obj = json.loads(responseString)
141-
return Response(obj["licenseKey"], obj["signature"], obj["result"],obj["message"])
141+
142+
licenseKey = ""
143+
signature = ""
144+
result = ""
145+
message = ""
146+
147+
if "licenseKey" in obj:
148+
licenseKey = obj["licenseKey"]
149+
150+
if "signature" in obj:
151+
signature = obj["signature"]
152+
153+
if "message" in obj:
154+
message = obj["message"]
155+
156+
if "result" in obj:
157+
result = obj["result"]
158+
else:
159+
result = 1
160+
161+
return Response(licenseKey, signature, result, message)
142162

143163
class RSAPublicKey:
144164

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
setup(
33
name = 'licensing', # How you named your package folder (MyLib)
44
packages = ['licensing'], # Chose the same as "name"
5-
version = '0.6', # Start with a small number and increase it with every change you make
5+
version = '0.7', # Start with a small number and increase it with every change you make
66
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
77
description = 'Client library for Cryptolens licensing Web API.', # Give a short description about your library
88
author = 'Cryptolens AB', # Type in your name
99
author_email = '[email protected]', # Type in your E-Mail
1010
url = 'https://cryptolens.io', # Provide either the link to your github or to your website
11-
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_06.tar.gz', # I explain this later on
11+
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_07.tar.gz', # I explain this later on
1212
keywords = ['software licensing', 'licensing library', 'cryptolens'], # Keywords that define your package best
1313
install_requires=[ # I get to this in a second
1414
'pycryptodome'

test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
pubKey = "<RSAKeyValue><Modulus>sGbvxwdlDbqFXOMlVUnAF5ew0t0WpPW7rFpI5jHQOFkht/326dvh7t74RYeMpjy357NljouhpTLA3a6idnn4j6c3jmPWBkjZndGsPL4Bqm+fwE48nKpGPjkj4q/yzT4tHXBTyvaBjA8bVoCTnu+LiC4XEaLZRThGzIn5KQXKCigg6tQRy0GXE13XYFVz/x1mjFbT9/7dS8p85n8BuwlY5JvuBIQkKhuCNFfrUxBWyu87CFnXWjIupCD2VO/GbxaCvzrRjLZjAngLCMtZbYBALksqGPgTUN7ZM24XbPWyLtKPaXF2i4XRR9u6eTj5BfnLbKAU5PIVfjIS+vNYYogteQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"
1212

13-
res = Key.activate(token="WyIyNjA1IiwiTjhZQUpIYXJPaVdBV0ozQUlKVC9tamdDbFZDRzhZRHpaU243L2R2eCJd",\
13+
res = Key.activate(token="WyIyNzMyIiwiYmx6NlJ6ZzdaWjFScmxFVFNCc283YTJyUG5kQURMZ0hucW1YdUZxKyJd",\
1414
rsa_pub_key=pubKey,\
1515
product_id=3349, key="ICVLD-VVSZR-ZTICT-YKGXL", machine_code=Helpers.GetMachineCode())
1616

0 commit comments

Comments
 (0)