Skip to content

Commit

Permalink
refactor(chalice): changed logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tahayk committed Jan 26, 2024
1 parent 16af8ee commit c9639d0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ee/api/chalicelib/core/unlock.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import uuid
from os import environ

Expand All @@ -7,6 +8,8 @@
from chalicelib.utils import helper
from chalicelib.utils.TimeUTC import TimeUTC

logger = logging.getLogger(__name__)


def __get_mid():
return str(uuid.UUID(int=uuid.getnode()))
Expand All @@ -19,15 +22,16 @@ def get_license():
def check():
license = get_license()
if license is None or len(license) == 0:
print("!! license key not found, please provide a LICENSE_KEY env var")
logger.warning("!! license key not found, please provide a LICENSE_KEY env var")
environ["expiration"] = "-1"
environ["numberOfSeats"] = "0"
return
print(f"validating: {helper.obfuscate(license)}")
r = requests.post('https://api.openreplay.com/license/validate', json={"mid": __get_mid(), "license": get_license()})
logger.info(f"validating: {helper.obfuscate(license)}")
r = requests.post('https://api.openreplay.com/license/validate',
json={"mid": __get_mid(), "license": get_license()})
if r.status_code != 200 or "errors" in r.json() or not r.json()["data"].get("valid"):
print("license validation failed")
print(r.text)
logger.warning("license validation failed")
logger.warning(r.text)
environ["expiration"] = "-1"
else:
environ["expiration"] = str(r.json()["data"].get("expiration"))
Expand Down

0 comments on commit c9639d0

Please sign in to comment.