33 lines
777 B
Python
33 lines
777 B
Python
import sys
|
|||
|
|
import os
|
||
|
|
from src.security import validate_license
|
||
|
|
LICENSE_PATH = os.path.expanduser("~/.app_license")
|
||
|
|
|
||
|
|
|
||
|
|
def check_license():
|
||
|
|
"""强制许可证验证"""
|
||
|
|
if not os.path.exists(LICENSE_PATH):
|
||
|
|
print("错误:未找到许可证文件")
|
||
|
|
return False
|
||
|
|
|
||
|
|
with open(LICENSE_PATH, 'r') as f:
|
||
|
|
license_code = f.read().strip()
|
||
|
|
|
||
|
|
valid, message = validate_license(license_code)
|
||
|
|
if not valid:
|
||
|
|
print(f"授权失败: {message}")
|
||
|
|
return False
|
||
|
|
return True
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
print("=== 软件启动验证 ===")
|
||
|
|
if not check_license():
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
print("授权验证成功!欢迎使用本软件")
|
||
|
|
# 此处添加主程序逻辑
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|