Skip to content

Commit de6718d

Browse files
committed
Add friendly name in both Python clients
1 parent 93327d5 commit de6718d

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

cryptolens_python2.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class Key:
208208
@staticmethod
209209
def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return = 0,\
210210
metadata = False, floating_time_interval = 0,\
211-
max_overdraft = 0):
211+
max_overdraft = 0, friendly_name=None):
212212

213213
"""
214214
Calls the Activate method in Web API 3 and returns a tuple containing
@@ -229,6 +229,8 @@ def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return
229229
"metadata":metadata,\
230230
"FloatingTimeInterval": floating_time_interval,\
231231
"MaxOverdraft": max_overdraft,\
232+
"FriendlyName" : friendly_name,\
233+
"ModelVersion" : 2,\
232234
"Sign":"True",\
233235
"SignMethod":1}))
234236
except HTTPError as e:
@@ -418,12 +420,13 @@ def IsOnRightMachine(license_key, is_floating_license = False, allow_overdraft=F
418420
import time
419421

420422
class ActivatedMachine:
421-
def __init__(self, IP, Mid, Time):
423+
def __init__(self, IP, Mid, Time, FriendlyName = ""):
422424
self.IP = IP
423425
self.Mid = Mid
424426

425427
# TODO: check if time is int, and convert to datetime in this case.
426428
self.Time = Time
429+
self.FriendlyName = FriendlyName
427430

428431
class LicenseKey:
429432

licensing/methods.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Key:
2222
@staticmethod
2323
def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return = 0,\
2424
metadata = False, floating_time_interval = 0,\
25-
max_overdraft = 0):
25+
max_overdraft = 0, friendly_name = None):
2626

2727
"""
2828
Calls the Activate method in Web API 3 and returns a tuple containing
@@ -43,6 +43,8 @@ def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return
4343
"metadata":metadata,\
4444
"FloatingTimeInterval": floating_time_interval,\
4545
"MaxOverdraft": max_overdraft,\
46+
"FriendlyName" : friendly_name,\
47+
"ModelVersion": 2 ,\
4648
"Sign":"True",\
4749
"SignMethod":1}))
4850
except HTTPError as e:

licensing/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
from licensing.internal import HelperMethods
1515

1616
class ActivatedMachine:
17-
def __init__(self, IP, Mid, Time):
17+
def __init__(self, IP, Mid, Time, FriendlyName=""):
1818
self.IP = IP
1919
self.Mid = Mid
2020

2121
# TODO: check if time is int, and convert to datetime in this case.
2222
self.Time = Time
23+
self.FriendlyName = FriendlyName
2324

2425
class LicenseKey:
2526

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
setup(
33
name = 'licensing', # How you named your package folder (MyLib)
44
packages = ['licensing'], # Chose the same as "name"
5-
version = '0.16', # Start with a small number and increase it with every change you make
5+
version = '0.17', # 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

test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
from licensing.models import *
99
from licensing.methods import Key, Helpers
1010

11+
import socket
12+
1113
#from cryptolens_python2 import *
1214
pubKey = "<RSAKeyValue><Modulus>sGbvxwdlDbqFXOMlVUnAF5ew0t0WpPW7rFpI5jHQOFkht/326dvh7t74RYeMpjy357NljouhpTLA3a6idnn4j6c3jmPWBkjZndGsPL4Bqm+fwE48nKpGPjkj4q/yzT4tHXBTyvaBjA8bVoCTnu+LiC4XEaLZRThGzIn5KQXKCigg6tQRy0GXE13XYFVz/x1mjFbT9/7dS8p85n8BuwlY5JvuBIQkKhuCNFfrUxBWyu87CFnXWjIupCD2VO/GbxaCvzrRjLZjAngLCMtZbYBALksqGPgTUN7ZM24XbPWyLtKPaXF2i4XRR9u6eTj5BfnLbKAU5PIVfjIS+vNYYogteQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"
1315
#HelperMethods.ironpython2730_legacy = True
1416
res = Key.activate(token="WyIyNzMyIiwiYmx6NlJ6ZzdaWjFScmxFVFNCc283YTJyUG5kQURMZ0hucW1YdUZxKyJd",\
1517
rsa_pub_key=pubKey,\
16-
product_id=3349, key="ICVLD-VVSZR-ZTICT-YKGXL", machine_code=Helpers.GetMachineCode())
18+
product_id=3349, key="ICVLD-VVSZR-ZTICT-YKGXL", machine_code=Helpers.GetMachineCode(),\
19+
friendly_name=socket.gethostname())
1720

1821
if res[0] == None or not Helpers.IsOnRightMachine(res[0]):
1922
print("An error occured: {0}".format(res[1]))

0 commit comments

Comments
 (0)