You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.2 KiB
Python

import time
import datetime
import logging
from website import consts, settings
def get_license_status(license):
status = consts.system_status_not_active
# if not license:
# pass
if license:
now = datetime.datetime.now()
timestamp_now = int(now.timestamp())
expireat = int(license["expireat"])
expireat_datetime = datetime.datetime.fromtimestamp(expireat)
expireat_next30days = expireat_datetime + datetime.timedelta(days=30)
expireat_next30days_timestamp = int(expireat_next30days.timestamp())
time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
# logging.info(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(expireat)))
# logging.info(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(expireat_next30days_timestamp)))
# logging.info(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp_now)))
if timestamp_now >= expireat_next30days_timestamp:
status = consts.system_status_expire_atall
elif timestamp_now >= expireat and timestamp_now < expireat_next30days_timestamp:
status = consts.system_status_expire_but_ok
elif timestamp_now < expireat:
status = consts.system_status_activated
return status