Skip to content

Commit bd2c9f3

Browse files
committed
Mark all static methods for python2 compatibility
1 parent 4c7a237 commit bd2c9f3

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

licensing/internal.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ class HelperMethods:
1616

1717
server_address = "https://app.cryptolens.io/api/"
1818

19+
@staticmethod
1920
def get_SHA256(string):
2021
"""
2122
Compute the SHA256 signature of a string.
2223
"""
2324
return hashlib.sha256(string.encode("utf-8")).hexdigest()
2425

25-
26+
@staticmethod
2627
def verify_signature(response, rsaPublicKey):
2728
"""
2829
Verifies a signature from .NET RSACryptoServiceProvider.
@@ -33,12 +34,15 @@ def verify_signature(response, rsaPublicKey):
3334
verifier = PKCS1_v1_5.new(cryptoPubKey)
3435
return verifier.verify(h, base64.b64decode(response.signature.encode("utf-8")))
3536

37+
@staticmethod
3638
def int2base64(num):
3739
return base64.b64encode(int.to_bytes(num), byteorder='big')
3840

41+
@staticmethod
3942
def base642int(string):
4043
return int.from_bytes(base64.b64decode((string)), byteorder='big')
4144

45+
@staticmethod
4246
def send_request(method, params):
4347
"""
4448
Send a POST request to method in the Web API with the specified
@@ -51,7 +55,7 @@ def send_request(method, params):
5155
urllib.parse.urlencode(params)\
5256
.encode("utf-8")).read().decode("utf-8")
5357

54-
58+
@staticmethod
5559
def start_process(command):
5660

5761
process = Popen(command, stdout=PIPE)

licensing/methods.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Key:
1818
License key related methods. More docs: https://app.cryptolens.io/docs/api/v3/Key.
1919
"""
2020

21+
@staticmethod
2122
def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return = 0,\
2223
metadata = False, floating_time_interval = 0,\
2324
max_overdraft = 0):
@@ -58,7 +59,8 @@ def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return
5859
return (None, "The signature check failed.")
5960
except Exception:
6061
return (None, "The signature check failed.")
61-
62+
63+
@staticmethod
6264
def create_trial_key(token, product_id, machine_code):
6365
"""
6466
Calls the CreateTrialKey method in Web API 3 and returns a tuple containing
@@ -87,7 +89,7 @@ def create_trial_key(token, product_id, machine_code):
8789

8890
return (jobj["key"], "")
8991

90-
92+
@staticmethod
9193
def deactivate(token, product_id, key, machine_code, floating = False):
9294
"""
9395
Calls the Deactivate method in Web API 3 and returns a tuple containing
@@ -122,6 +124,7 @@ def deactivate(token, product_id, key, machine_code, floating = False):
122124

123125
class Helpers:
124126

127+
@staticmethod
125128
def GetMachineCode():
126129

127130
"""
@@ -138,6 +141,7 @@ def GetMachineCode():
138141
else:
139142
return HelperMethods.get_SHA256(HelperMethods.compute_machine_code())
140143

144+
@staticmethod
141145
def IsOnRightMachine(license_key, is_floating_license = False, allow_overdraft=False):
142146

143147
"""

licensing/models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(self, ProductId, ID, Key, Created, Expires, Period, F1, F2,\
5454
self.sign_date = SignDate
5555
self.raw_response = RawResponse
5656

57+
@staticmethod
5758
def from_response(response):
5859

5960
if response.result == "1":
@@ -78,6 +79,7 @@ def save_as_string(self):
7879
res.pop("license_key", None)
7980
return json.dumps(res)
8081

82+
@staticmethod
8183
def load_from_string(rsa_pub_key, string, signature_expiration_interval = -1):
8284
"""
8385
Loads a license from a string generated by save_as_string.
@@ -115,7 +117,8 @@ def load_from_string(rsa_pub_key, string, signature_expiration_interval = -1):
115117
return None
116118
except Exception:
117119
return None
118-
120+
121+
@staticmethod
119122
def __load_activated_machines(obj):
120123

121124
if obj == None:
@@ -136,6 +139,7 @@ def __init__(self, license_key, signature, result, message):
136139
self.result = result
137140
self.message = message
138141

142+
@staticmethod
139143
def from_string(responseString):
140144
obj = json.loads(responseString)
141145

@@ -166,6 +170,7 @@ def __init__(self, modulus, exponent):
166170
self.modulus = modulus
167171
self.exponent = exponent
168172

173+
@staticmethod
169174
def from_string(rsaPubKeyString):
170175
"""
171176
The rsaPubKeyString can be found at https://app.cryptolens.io/User/Security.

0 commit comments

Comments
 (0)