This repository has been archived on 2022-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
gmclcore/GMCLCore/__init__.py

78 lines
2.5 KiB
Python
Executable File

# -*- coding: utf-8 -*-
#
# ________ _____ _________ .____ _________
# / _____/ / \ \_ ___ \| | \_ ___ \ ___________ ____
# / \ ___ / \ / \/ \ \/| | / \ \/ / _ \_ __ _/ __ \
# \ \_\ / Y \ \___| |__\ \___( <_> | | \\ ___/
# \______ \____|__ /\______ |_______ \______ /\____/|__| \___ >
# \/ \/ \/ \/ \/ \/
#
# Ghink Minecraft Launcher
# Copyleft Ghink Network Studio
# Bigsk (https://www.xiaxinzhe.cn)
# See the LICENSE
#
import os, platform
import urllib.request
def networkTest(source = r"http://www.baidu.com", retry = 3):
flag = False
for i in range(retry):
try:
fp = urllib.request.urlopen(source)
fp.read(100).decode()
fp.close()
except:
pass
else:
flag = True
return flag
modules = (
"psutil",
"requests"
)
retry = 3
mirrors = "https://pypi.tuna.tsinghua.edu.cn/simple"
for m in modules:
try:
exec("import {}".format(m))
except Exception as e:
print(e)
if networkTest():
for i in range(retry):
if platform.system == "Windows":
os.system("pip install -i {} {}".format(mirrors, m))
else:
os.system("pip3 install -i {} {}".format(mirrors, m))
try:
exec("import {}".format(m))
except:
if i == retry - 1:
raise ImportError("Failed to import modules {}! ".format(m))
else:
break
else:
raise ImportError("Failed to import modules {}! ".format(m))
from GMCLCore.config import *
__version__ = "{} {}".format(VERSION[0], ".".join(str(c) for c in VERSION[1]))
__name__ = "GMCLCore"
__all__ = []
from GMCLCore.main import *
print("Welcome to GMCLCore {}!".format(__version__))
print(
'''
________ _____ _________ .____ _________
/ _____/ / \ \_ ___ \| | \_ ___ \ ___________ ____
/ \ ___ / \ / \/ \ \/| | / \ \/ / _ \_ __ _/ __ \
\ \_\ / Y \ \___| |__\ \___( <_> | | \\ ___/
\______ \____|__ /\______ |_______ \______ /\____/|__| \___ >
\/ \/ \/ \/ \/ \/
'''
)