feat: 增加日志输出,增加友善的提示

This commit is contained in:
cheng zhen
2025-01-03 11:40:31 +08:00
parent 6403682094
commit f0960f21a9
2 changed files with 10 additions and 11 deletions

View File

@@ -17,7 +17,7 @@ from get_veri_code import EmailVerificationHandler
# 在文件开头设置日志
logging.basicConfig(
level=logging.WARNING,
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[
logging.StreamHandler(),
@@ -309,11 +309,9 @@ def sign_up_account(browser, tab):
print("可用上限: " + total_usage)
except Exception as e:
print("获取可用上限失败")
# tab.get_screenshot("sign_up_success.png")
# print("注册账户截图")
print("注册完成")
print("Cursor 账号: " + account)
print(" 密码: " + password)
account_info = f"\nCursor 账号: {account} 密码: {password}"
logging.info(account_info)
time.sleep(5)
return True

View File

@@ -24,8 +24,10 @@ class LicenseManager:
config_dir = os.path.expanduser("~/.config")
self.license_file = os.path.join(config_dir, "CursorPro", "license.json")
self.activation_url = "http://cursor.chengazhen.me/activate"
self.verify_url = "http://cursor.chengazhen.me/verify"
# self.activation_url = "http://cursor.chengazhen.me/activate"
# self.verify_url = "http://cursor.chengazhen.me/verify"
self.activation_url = "http://127.0.0.1:3000/activate"
self.verify_url = "http://127.0.0.1:3000/verify"
self.key = b"Kj8nP9x2Qs5mY7vR4wL1hC3fA6tD0iB8"
self.encryption_key = b"f1e2d3c4b5a6978899aabbccddeeff00112233445566778899aabbccddeeff00" # 与服务器端相同的密钥
@@ -97,19 +99,18 @@ class LicenseManager:
response = requests.post(
self.activation_url, json=activation_data, timeout=10
)
if response.status_code == 200:
try:
encrypted_response = response.json()
result = self.decrypt_response(
encrypted_response["encrypted_data"]
)
if result.get("success"):
if result.get("code") == 0:
license_data = {
"license_key": license_key,
"machine_code": machine_code,
"activation_date": activation_data["activation_date"],
"expiry_date": result.get("expiry_date"),
"expiry_date": result.get("data").get("expiry_date"),
"is_active": True,
}
self._save_license(license_data)
@@ -189,7 +190,7 @@ class LicenseManager:
result = self.decrypt_response(
encrypted_response["encrypted_data"]
)
if result.get("success"):
if result.get("code") == 0:
return True, "许可证有效"
return False, result.get("message", "许可证无效")
except Exception as e: