2023-05-10 17:44:39 +08:00
|
|
|
|
import sys
|
|
|
|
|
import os
|
2023-05-12 19:30:07 +08:00
|
|
|
|
import urllib.request
|
2023-05-12 21:38:02 +08:00
|
|
|
|
import webbrowser
|
2023-05-12 22:40:41 +08:00
|
|
|
|
from time import sleep, strftime
|
2023-08-27 11:49:10 +08:00
|
|
|
|
import subprocess
|
2023-05-10 17:44:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ml = os.getcwd()
|
|
|
|
|
file_error = '文件丢失,请重新安装!!'
|
2023-05-12 22:40:41 +08:00
|
|
|
|
ERROR_MSG = '错误:'
|
2023-05-10 17:44:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def open_exe(exe_name):
|
|
|
|
|
if os.path.exists(os.path.join(ml, f"{exe_name}.exe")):
|
2023-08-27 11:49:10 +08:00
|
|
|
|
subprocess.Popen(f"{exe_name}.exe", shell=True)
|
2023-05-10 17:44:39 +08:00
|
|
|
|
else:
|
|
|
|
|
print(file_error)
|
|
|
|
|
sleep(1)
|
2023-05-12 22:40:41 +08:00
|
|
|
|
|
|
|
|
|
|
2023-05-12 21:44:50 +08:00
|
|
|
|
def check_internet(url='http://www.baidu.com/', timeout=5):
|
2023-05-12 19:30:07 +08:00
|
|
|
|
try:
|
|
|
|
|
urllib.request.urlopen(url, timeout=timeout)
|
2023-05-13 13:00:29 +08:00
|
|
|
|
open_exe('client')
|
2023-05-12 19:30:07 +08:00
|
|
|
|
return True
|
|
|
|
|
except Exception as e:
|
2023-05-12 22:40:41 +08:00
|
|
|
|
print(f'{ERROR_MSG}{strftime("%Y-%m-%d %H:%M:%S")}: WIFI连接不正常,请检测wifi连接后再试吧')
|
2023-05-12 19:30:07 +08:00
|
|
|
|
sleep(5)
|
2023-05-12 21:38:02 +08:00
|
|
|
|
print('是否继续启动程序(Y.是,N.不是)?')
|
2023-05-12 20:19:58 +08:00
|
|
|
|
input_xz = str(input('>>>'))
|
|
|
|
|
if input_xz != None:
|
2023-05-12 22:40:41 +08:00
|
|
|
|
if input_xz.lower() == 'y':
|
2023-05-12 20:19:58 +08:00
|
|
|
|
open_exe('client')
|
2023-05-12 22:40:41 +08:00
|
|
|
|
elif input_xz.lower() == 'n':
|
2023-05-12 20:19:58 +08:00
|
|
|
|
sys.exit()
|
|
|
|
|
else:
|
|
|
|
|
print('请输入英文字母!!')
|
|
|
|
|
sleep(1.5)
|
|
|
|
|
else:
|
|
|
|
|
print('错误:没有输入文字')
|
|
|
|
|
sleep(1.5)
|
2023-05-12 19:30:07 +08:00
|
|
|
|
return False
|
2023-05-10 17:44:39 +08:00
|
|
|
|
|
2023-05-12 22:40:41 +08:00
|
|
|
|
|
2023-05-13 13:00:29 +08:00
|
|
|
|
'''def check_python_installation():
|
2023-05-12 22:25:13 +08:00
|
|
|
|
if sys.version_info.major < 3:
|
2023-05-12 22:54:26 +08:00
|
|
|
|
python_path = None
|
|
|
|
|
# 检查是否有 Python 安装目录
|
|
|
|
|
for path in os.environ['PATH'].split(os.pathsep):
|
|
|
|
|
python_exe = os.path.join(path, 'python.exe')
|
|
|
|
|
if os.path.isfile(python_exe):
|
|
|
|
|
python_path = os.path.dirname(python_exe)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if python_path:
|
|
|
|
|
print(f'{ERROR_MSG}{strftime("%Y-%m-%d %H:%M:%S")}: Python已安装,但版本太低,请安装 Python 3.x 版本')
|
|
|
|
|
webbrowser.open('https://python.org/downloads/')
|
|
|
|
|
else:
|
|
|
|
|
print(f'{ERROR_MSG}{strftime("%Y-%m-%d %H:%M:%S")}: Python未安装,请安装 Python 3.x 版本')
|
|
|
|
|
webbrowser.open('https://python.org/downloads/')
|
|
|
|
|
|
2023-05-13 13:00:29 +08:00
|
|
|
|
print('是否继续启动程序(Y.是,N.不是)?')
|
|
|
|
|
input_xz = str(input('>>>'))
|
|
|
|
|
if input_xz != None:
|
|
|
|
|
if input_xz.lower() == 'y':
|
|
|
|
|
open_exe('client')
|
|
|
|
|
elif input_xz.lower() == 'n':
|
|
|
|
|
sys.exit()
|
|
|
|
|
else:
|
|
|
|
|
print('请输入英文字母!!')
|
|
|
|
|
sleep(1.5)
|
2023-05-12 22:25:13 +08:00
|
|
|
|
else:
|
2023-05-13 13:00:29 +08:00
|
|
|
|
print('错误:没有输入文字,默认退出!')
|
2023-05-12 22:25:13 +08:00
|
|
|
|
sleep(1.5)
|
2023-05-13 13:00:29 +08:00
|
|
|
|
sys.exit()
|
2023-05-12 22:54:26 +08:00
|
|
|
|
else:
|
2023-05-13 13:00:29 +08:00
|
|
|
|
python_path = None
|
|
|
|
|
for path in os.environ['PATH'].split(os.pathsep):
|
|
|
|
|
python_exe = os.path.join(path, 'python.exe')
|
|
|
|
|
if os.path.isfile(python_exe):
|
|
|
|
|
python_path = os.path.dirname(python_exe)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if python_path:
|
|
|
|
|
print('自检正常!')
|
|
|
|
|
open_exe('client')
|
|
|
|
|
else:
|
|
|
|
|
print(f'{ERROR_MSG}{strftime("%Y-%m-%d %H:%M:%S")}: Python未安装,请安装 Python 3.x 版本')
|
|
|
|
|
webbrowser.open('https://python.org/downloads/')
|
|
|
|
|
|
|
|
|
|
print('是否继续启动程序(Y.是,N.不是)?')
|
|
|
|
|
input_xz = str(input('>>>'))
|
|
|
|
|
if input_xz != None:
|
|
|
|
|
if input_xz.lower() == 'y':
|
|
|
|
|
open_exe('client')
|
|
|
|
|
elif input_xz.lower() == 'n':
|
|
|
|
|
sys.exit()
|
|
|
|
|
else:
|
|
|
|
|
print('请输入英文字母!!')
|
|
|
|
|
sleep(1.5)
|
|
|
|
|
else:
|
|
|
|
|
print('错误:没有输入文字,默认退出!')
|
|
|
|
|
sleep(1.5)
|
|
|
|
|
sys.exit()'''
|
2023-05-12 22:40:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2023-08-28 14:08:00 +08:00
|
|
|
|
check_internet()
|
|
|
|
|
sys.exit()
|