licensing 0.47__tar.gz → 0.48__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: licensing
3
- Version: 0.47
3
+ Version: 0.48
4
4
  Summary: Client library for Cryptolens licensing Web API.
5
5
  Home-page: https://cryptolens.io
6
6
  Author: Cryptolens AB
7
7
  Author-email: support@cryptolens.io
8
8
  License: MIT
9
- Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/v_47.tar.gz
9
+ Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/v_48.tar.gz
10
10
  Description: UNKNOWN
11
11
  Keywords: software licensing,licensing library,cryptolens
12
12
  Platform: UNKNOWN
@@ -17,3 +17,13 @@ Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3.4
18
18
  Classifier: Programming Language :: Python :: 3.5
19
19
  Classifier: Programming Language :: Python :: 3.6
20
+ Classifier: Programming Language :: Python :: 3.7
21
+ Classifier: Programming Language :: Python :: 3.8
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Operating System :: OS Independent
27
+ Classifier: Operating System :: POSIX :: Linux
28
+ Classifier: Operating System :: Microsoft :: Windows
29
+ Classifier: Operating System :: MacOS :: MacOS X
@@ -1361,6 +1361,40 @@ class PaymentForm:
1361
1361
  return (jobj, "")
1362
1362
 
1363
1363
  class Helpers:
1364
+
1365
+
1366
+ def __read_registry_value(key, subkey, value_name):
1367
+
1368
+ import winreg
1369
+
1370
+ """
1371
+ Reads a value from the Windows Registry.
1372
+
1373
+ Parameters:
1374
+ key (int): The registry root key (e.g., winreg.HKEY_LOCAL_MACHINE).
1375
+ subkey (str): The path to the subkey.
1376
+ value_name (str): The name of the value to read.
1377
+
1378
+ Returns:
1379
+ str: The value read from the registry, or an error message if not found.
1380
+ """
1381
+ try:
1382
+ # Open the registry key
1383
+ registry_key = winreg.OpenKey(key, subkey, 0, winreg.KEY_READ)
1384
+
1385
+ # Query the value
1386
+ value, reg_type = winreg.QueryValueEx(registry_key, value_name)
1387
+
1388
+ # Close the registry key
1389
+ winreg.CloseKey(registry_key)
1390
+
1391
+ return value
1392
+
1393
+ except FileNotFoundError:
1394
+ return None
1395
+ except Exception as e:
1396
+ return None #str(e)
1397
+
1364
1398
 
1365
1399
  @staticmethod
1366
1400
  def GetMachineCode(v=1):
@@ -1374,15 +1408,21 @@ class Helpers:
1374
1408
  """
1375
1409
 
1376
1410
  if "windows" in platform.platform().lower():
1377
-
1411
+
1412
+ import winreg
1413
+
1378
1414
  seed = ""
1379
1415
 
1380
1416
  if v==2:
1381
1417
  seed = HelperMethods.start_process_ps_v2()
1382
1418
  else:
1383
1419
  seed = HelperMethods.start_process(["cmd.exe", "/C", "wmic","csproduct", "get", "uuid"],v)
1420
+
1421
+ if seed == "" or seed == None:
1422
+ machineGUID = Helpers.__read_registry_value(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Cryptography", "MachineGuid")
1384
1423
 
1385
- if seed == "":
1424
+ if machineGUID != None and machineGUID != "":
1425
+ HelperMethods.get_SHA256(machineGUID)
1386
1426
  return None
1387
1427
  else:
1388
1428
  return HelperMethods.get_SHA256(seed)
@@ -1453,6 +1493,31 @@ class Helpers:
1453
1493
 
1454
1494
  return ':'.join(['{:02x}'.format((uuid.getnode() >> ele) & 0xff) for ele in range(0,8*6,8)][::-1])
1455
1495
 
1496
+ def HasNotExpired(license_key, allow_usage_on_expiry_date=True):
1497
+
1498
+ """
1499
+ Checks that the license key has not expired. Cryptolens offers automatic blocking of licenses
1500
+ on the server side, and it is recommended to set it up instead of relying on the client side (unless
1501
+ your application is running in offline mode). For more details, please review
1502
+ https://help.cryptolens.io/web-interface/keys-that-dont-expire
1503
+
1504
+ Parameters:
1505
+ @license_key The license key object.
1506
+ @allow_usage_on_expiry_date If set to true, the license will be considered valid on the day it expires.
1507
+ """
1508
+
1509
+ import datetime
1510
+
1511
+ if license_key == None:
1512
+ return False
1513
+
1514
+ diff = license_key.expires.replace(tzinfo=datetime.timezone.utc) - datetime.datetime.now(datetime.timezone.utc)
1515
+
1516
+ if allow_usage_on_expiry_date and diff >= datetime.timedelta(0) or not(allow_usage_on_expiry_date) and diff > 0:
1517
+ return True
1518
+
1519
+ return False
1520
+
1456
1521
  def HasFeature(license_key, feature_name):
1457
1522
 
1458
1523
  """
@@ -2,13 +2,13 @@ from distutils.core import setup
2
2
  setup(
3
3
  name = 'licensing', # How you named your package folder (MyLib)
4
4
  packages = ['licensing'], # Chose the same as "name"
5
- version = '0.47', # Start with a small number and increase it with every change you make
5
+ version = '0.48', # Start with a small number and increase it with every change you make
6
6
  license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
7
7
  description = 'Client library for Cryptolens licensing Web API.', # Give a short description about your library
8
8
  author = 'Cryptolens AB', # Type in your name
9
9
  author_email = 'support@cryptolens.io', # Type in your E-Mail
10
10
  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_47.tar.gz', # I explain this later on
11
+ download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_48.tar.gz', # I explain this later on
12
12
  keywords = ['software licensing', 'licensing library', 'cryptolens'], # Keywords that define your package best
13
13
  classifiers=[
14
14
  #'Development Status :: 5 - Stable', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
@@ -19,5 +19,15 @@ setup(
19
19
  'Programming Language :: Python :: 3.4',
20
20
  'Programming Language :: Python :: 3.5',
21
21
  'Programming Language :: Python :: 3.6',
22
+ 'Programming Language :: Python :: 3.7',
23
+ 'Programming Language :: Python :: 3.8',
24
+ 'Programming Language :: Python :: 3.9',
25
+ 'Programming Language :: Python :: 3.10',
26
+ 'Programming Language :: Python :: 3.11',
27
+ 'Programming Language :: Python :: 3.12',
28
+ 'Operating System :: OS Independent',
29
+ 'Operating System :: POSIX :: Linux',
30
+ 'Operating System :: Microsoft :: Windows',
31
+ 'Operating System :: MacOS :: MacOS X',
22
32
  ],
23
33
  )
File without changes
File without changes
File without changes
File without changes