Skip to content

Commit

Permalink
1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-zehentleitner committed Oct 6, 2023
1 parent c92c240 commit 2e8f503
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ jobs:
generate_release_notes: true
name: lucit-licensing-python
prerelease: false
tag_name: 1.1.1
tag_name: 1.1.2
token: ${{ secrets.RELEASE_TOKEN }}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

[How to upgrade to the latest version!](https://lucit-licensing-python.docs.lucit.tech/README.html#installation-and-upgrade)

## 1.1.1.dev (development stage/unreleased/unstable)
## 1.1.2.dev (development stage/unreleased/unstable)

## 1.1.1
## 1.1.2
- RELEASE!!! :)
42 changes: 25 additions & 17 deletions lucit_licensing_python/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from operator import itemgetter
from requests.exceptions import ConnectionError, RequestException, HTTPError
from simplejson.errors import JSONDecodeError
from exceptions import NoValidLucitLicense

logger = logging.getLogger("lucit-licensing-logger")

Expand All @@ -45,7 +46,7 @@ def __init__(self, api_secret: str = None, license_token: str = None,
self.last_verified_licensing_result = None
self.license_token = license_token
self.mac = str(hex(uuid.getnode()))
self.module_version: str = "1.1.1"
self.module_version: str = "1.1.2"
self.needed_license_type = needed_license_type
self.os = platform.system()
self.parent_shutdown_function = parent_shutdown_function
Expand Down Expand Up @@ -174,7 +175,8 @@ def __verify_signature(self, api_secret: str = None, params: dict = None, signat
return False

def close(self, close_api_session: bool = True, not_approved_message: str = None,
key_value: str = None) -> dict:
key_value: str = None, raise_exception: bool = False) -> dict:
info = None
if not_approved_message is not None:
info = f"Stopping, no valid {self.needed_license_type} license verification! {not_approved_message}"
print(info)
Expand All @@ -185,10 +187,13 @@ def close(self, close_api_session: bool = True, not_approved_message: str = None
if self.parent_shutdown_function is not None:
self.parent_shutdown_function(close_api_session=False)
if close_api_session is True:
return self.__private_request(api_secret=None, license_token=None,
key_value=key_value, endpoint="close")
response = self.__private_request(api_secret=None, license_token=None,
key_value=key_value, endpoint="close")
else:
return {"close": {"status": "NOT_EXECUTED"}}
response = {"close": {"status": "NOT_EXECUTED"}}
if raise_exception is True:
raise NoValidLucitLicense(info)
return response

def get_module_version(self):
return self.module_version
Expand Down Expand Up @@ -219,7 +224,7 @@ def run(self):
f"'{license_result['license']['licensed_product']}'. Please contact our support: " \
f"https://www.lucit.tech/get-support.html"
logger.critical(info)
self.close(close_api_session=False, not_approved_message=info)
self.close(close_api_session=False, not_approved_message=info, raise_exception=True)
break
else:
if license_result['license']['status'] == "VALID":
Expand All @@ -236,7 +241,7 @@ def run(self):
else:
info = f"Unsuccessful verification! License Status: {license_result['license']['status']}"
logger.critical(info)
self.close(close_api_session=False, not_approved_message=info)
self.close(close_api_session=False, not_approved_message=info, raise_exception=True)
break
except KeyError:
if "403 Forbidden" in license_result['error']:
Expand All @@ -247,21 +252,23 @@ def run(self):
info = f"Access forbidden due to misuse of test licenses. Please get a valid license from " \
f"the LUCIT Online Shop: {self.shop_product_url}"
logger.critical(info)
self.close(close_api_session=False, not_approved_message=info)
self.close(close_api_session=False, not_approved_message=info, raise_exception=True)
break
elif "403 Forbidden - Insufficient access rights." in license_result['error']:
logger.critical(f"{license_result['error']}")
self.close(close_api_session=False,
not_approved_message=f"The license is invalid! Please get a valid license from "
f"the LUCIT Online Shop: {self.shop_product_url}")
f"the LUCIT Online Shop: {self.shop_product_url}",
raise_exception=True)
break
else:
logger.critical(f"{license_result['error']}")
self.close(close_api_session=True,
not_approved_message=f"Unknown error! Please submit an issue on GitHub: "
f"https://github.com/LUCIT-Systems-and-Development/"
f"lucit-licensing-python/issues/new?labels=bug&projects=&"
f"template=bug_report.yml")
f"template=bug_report.yml",
raise_exception=True)
break
elif "429 Too Many Requests" in license_result['error']:
logger.critical(f"{license_result['error']}")
Expand All @@ -271,7 +278,8 @@ def run(self):
f"license!")
self.close(close_api_session=False,
not_approved_message=f"Too many requests to the LUCIT Licensing API! Not able "
f"to verify the license!")
f"to verify the license!",
raise_exception=True)
break
else:
if connection_errors > 9:
Expand All @@ -281,7 +289,8 @@ def run(self):
f"license for more than 90 minutes!")
self.close(close_api_session=False,
not_approved_message=f"Too many requests to the LUCIT Licensing API! Not able "
f"to verify the license for more than 90 minutes!")
f"to verify the license for more than 90 minutes!",
raise_exception=True)
break
too_many_requests_errors += 1

Expand All @@ -298,7 +307,8 @@ def run(self):
f"try again later!")
self.close(close_api_session=False,
not_approved_message=f"Connection to LUCIT Licensing API could not be "
f"established. Please try again later!")
f"established. Please try again later!",
raise_exception=True)
break
connection_errors += 1
continue
Expand All @@ -316,10 +326,8 @@ def run(self):
else:
break

def stop(self, close_api_session: bool = True, not_approved_message: str = None, key_value: str = None) -> dict:
return self.close(close_api_session=close_api_session,
not_approved_message=not_approved_message,
key_value=key_value)
def stop(self) -> dict:
return self.close()

def sync_time(self) -> bool:
try:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'lucit_licensing_python/manager.py'],
annotate=False),
name='lucit-licensing-python',
version="1.1.1",
version="1.1.2",
author="LUCIT Systems and Development",
author_email='info@lucit.tech',
url="https://github.com/LUCIT-Systems-and-Development/lucit-licensing-python",
Expand Down

0 comments on commit 2e8f503

Please sign in to comment.