License key managaming for you project
Project description
License Checker for Python project
This module provides you with a wide functionality for checking license keys and their expiration dates for your program written in Python
Installing via PyPi
pip install license-key
JSON format
Need host JSON file to your site or on GitHub Gists with all licenses data with format:
{
"WZ3UD-ADZH8-MFYJB-RUGM3-J37TX": {
"id": "1",
"expire": "30.12.2022"
},
"EXAMPLE_KEY": {
"id": "ID ON STRING OR INT",
"expire": "DD.MM.YYYY"
}
}
Using in code
>>> import license_key
>>> url = "https://gist.github.com/marat2509/db7026b9dd10cbdbe63052c5d674804e/raw/licenses.json"
>>> license = init(license_json_url = url)
>>> print(license.check(license_key = "WZ3UD-ADZH8-MFYJB-RUGM3-J37TX"))
<<< 1 # License key valid
>>> print(license.check(license_key = "EXPIRED_KEY"))
<<< -1 # License key expired
>>> print(check_license(license_url_list = url, license_key = "UNKNOWN_KEY"))
<<< 0 # License key not registered
>>> print(license.get(license_key = "WZ3UD-ADZH8-MFYJB-RUGM3-J37TX", key = "expire"))
<<< 30.12.2022
>>> print(license.get(license_key = "WZ3UD-ADZH8-MFYJB-RUGM3-J37TX", key = "THIS_KEY_DOESNT_EXISTS"))
<<< -404 # Key not found
Status codes
| Code | Description |
|---|---|
| -406 | Failed to fetch |
| -404 | Key not found |
| -1 | License key expired |
| 0 | License key not found |
| 1 | License key valid |
Debug mode
Code:
import license_key
url = "https://gist.github.com/marat2509/db7026b9dd10cbdbe63052c5d674804e/raw/licenses.json"
license = license_key.init(license_json_url = url, debug = True)
print(license.check(license_key = "WZ3UD-ADZH8-MFYJB-RUGM3-J37TX"))
Output:
2022-06-17 23:34:20.553 | DEBUG | license_key:__init__:10 - Initiated self-based class; Version: 1.0.0
2022-06-17 23:34:20.873 | INFO | license_key:get_data:17 - Fetched JSON data, saved to dict 'self.data'
2022-06-17 23:34:20.877 | DEBUG | license_key:check:24 - Getting current date from TimeApi
2022-06-17 23:34:21.157 | INFO | license_key:check:28 - Fetched JSON data, saved dict to 'self.today'
2022-06-17 23:34:21.169 | DEBUG | license_key:check:32 - Setting 'self.to_day' from dict 'self.today'
2022-06-17 23:34:21.171 | INFO | license_key:check:34 - Setted 'self.to_day' to: 17
2022-06-17 23:34:21.201 | DEBUG | license_key:check:35 - Setting 'self.to_month' from dict 'self.today'
2022-06-17 23:34:21.203 | INFO | license_key:check:37 - Setted 'self.to_month' to: 6
2022-06-17 23:34:21.205 | DEBUG | license_key:check:38 - Setting 'self.to_year' from dict 'self.today'
2022-06-17 23:34:21.212 | INFO | license_key:check:40 - Setted 'self.to_year' to: 2022
2022-06-17 23:34:21.228 | DEBUG | license_key:check:41 - Checking license key in license list
2022-06-17 23:34:21.231 | INFO | license_key:check:45 - License key in a license list, license info:
{
"id": 1,
"expire": "30.12.2022"
}
2022-06-17 23:34:21.234 | DEBUG | license_key:check:46 - Checking whether the license key expired
2022-06-17 23:34:21.236 | INFO | license_key:check:55 - License key valid! The license key valid until: 30.12.2022
1
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
license-key-1.0.4.tar.gz
(15.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file license-key-1.0.4.tar.gz.
File metadata
- Download URL: license-key-1.0.4.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83cb8f0d2d5a199030cb7b3c4047ca007ebdf95cb15a9df609b1ec66a1a25876
|
|
| MD5 |
6e6632d817bed3648d96df031a24e8dc
|
|
| BLAKE2b-256 |
07ad43e806b7f0f8718e4fc0544de824566527b71d18504584df40f7d5765afc
|
File details
Details for the file license_key-1.0.4-py3-none-any.whl.
File metadata
- Download URL: license_key-1.0.4-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac101b443a25314b9879dbcba39c3940c3feca1484c8d45091da802d9b0dbb2d
|
|
| MD5 |
49bea953a93c6b244f2f93fb1c933515
|
|
| BLAKE2b-256 |
c598c6d66d761a905ee13580191096805427b7327731f82d8f350170d37a63ce
|