40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
import platform
|
|
import os
|
|
import subprocess
|
|
from logger import logging
|
|
|
|
def go_cursor_help():
|
|
system = platform.system()
|
|
logging.info(f"当前操作系统: {system}")
|
|
|
|
base_url = "https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run"
|
|
|
|
if system == "Darwin": # macOS
|
|
# 从环境变量获取密码
|
|
sudo_password = os.environ.get('SUDO_PASSWORD')
|
|
if sudo_password:
|
|
# 使用echo传递密码给sudo
|
|
cmd = f'echo "{sudo_password}" | sudo -S bash -c \'curl -fsSL {base_url}/cursor_mac_id_modifier.sh | bash\''
|
|
else:
|
|
cmd = f'curl -fsSL {base_url}/cursor_mac_id_modifier.sh | sudo bash'
|
|
|
|
logging.info("执行macOS命令")
|
|
result = os.system(cmd)
|
|
|
|
if result != 0:
|
|
raise Exception("执行命令失败,请检查密码是否正确")
|
|
elif system == "Linux":
|
|
cmd = f'curl -fsSL {base_url}/cursor_linux_id_modifier.sh | sudo bash'
|
|
logging.info("执行Linux命令")
|
|
os.system(cmd)
|
|
elif system == "Windows":
|
|
cmd = f'irm {base_url}/cursor_win_id_modifier.ps1 | iex'
|
|
logging.info("执行Windows命令")
|
|
# 在Windows上使用PowerShell执行命令
|
|
subprocess.run(["powershell", "-Command", cmd], shell=True)
|
|
else:
|
|
logging.error(f"不支持的操作系统: {system}")
|
|
return False
|
|
|
|
return True
|