迁移前提交
This commit is contained in:
parent
b0d4c8976e
commit
ac9679e522
BIN
._requirement.txt
Executable file
BIN
._requirement.txt
Executable file
Binary file not shown.
0
.gmclcore/env/aria2c64.exe
vendored
Normal file → Executable file
0
.gmclcore/env/aria2c64.exe
vendored
Normal file → Executable file
BIN
.gmclcore/env/aria2cdarwin
vendored
Executable file
BIN
.gmclcore/env/aria2cdarwin
vendored
Executable file
Binary file not shown.
@ -1,6 +0,0 @@
|
|||||||
[2022-01-09 12:32:21] [INFO] Initing running env...
|
|
||||||
[2022-01-09 12:32:24] [INFO] Creating daemon thread...
|
|
||||||
[2022-01-09 12:39:35] [INFO] Initing running env...
|
|
||||||
[2022-01-09 12:39:36] [INFO] Creating daemon thread...
|
|
||||||
[2022-01-09 12:43:55] [INFO] Initing running env...
|
|
||||||
[2022-01-09 12:43:56] [INFO] Creating daemon thread...
|
|
BIN
.gmclcore/logs/2022-02-04.zip
Executable file
BIN
.gmclcore/logs/2022-02-04.zip
Executable file
Binary file not shown.
53
.gmclcore/logs/2022-02-05.logs
Executable file
53
.gmclcore/logs/2022-02-05.logs
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
[2022-02-05 22:40:51] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:40:51] [INFO] Archiving logs.
|
||||||
|
[2022-02-05 22:41:22] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:41:22] [INFO] Archiving logs.
|
||||||
|
[2022-02-05 22:41:34] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:41:34] [INFO] Archiving logs.
|
||||||
|
[2022-02-05 22:42:40] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:42:40] [INFO] Archiving logs.
|
||||||
|
[2022-02-05 22:42:59] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:42:59] [INFO] Archiving logs.
|
||||||
|
[2022-02-05 22:44:35] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:44:35] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 22:46:59] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:46:59] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 22:47:17] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:47:17] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 22:47:48] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:47:48] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 22:47:58] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:47:58] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 22:48:36] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:48:36] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 22:49:11] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:49:11] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 22:50:17] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:50:17] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 22:50:31] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:50:31] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 22:55:18] [INFO] Initing running env...
|
||||||
|
[2022-02-05 22:55:18] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:03:44] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:03:46] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:04:35] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:04:35] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:04:39] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:04:39] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:04:52] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:05:13] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:05:13] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:05:23] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:05:23] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:08:12] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:08:12] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:08:20] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:08:20] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:09:55] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:09:55] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:10:30] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:10:30] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:11:14] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:11:14] [INFO] Creating daemon thread...
|
||||||
|
[2022-02-05 23:17:36] [INFO] Initing running env...
|
||||||
|
[2022-02-05 23:17:36] [INFO] Creating daemon thread...
|
0
GMCLCore/__init__.py
Normal file → Executable file
0
GMCLCore/__init__.py
Normal file → Executable file
0
GMCLCore/__main__.py
Normal file → Executable file
0
GMCLCore/__main__.py
Normal file → Executable file
BIN
GMCLCore/__pycache__/__init__.cpython-37.pyc
Normal file → Executable file
BIN
GMCLCore/__pycache__/__init__.cpython-37.pyc
Normal file → Executable file
Binary file not shown.
BIN
GMCLCore/__pycache__/__init__.cpython-38.pyc
Executable file
BIN
GMCLCore/__pycache__/__init__.cpython-38.pyc
Executable file
Binary file not shown.
0
GMCLCore/__pycache__/config.cpython-37.pyc
Normal file → Executable file
0
GMCLCore/__pycache__/config.cpython-37.pyc
Normal file → Executable file
BIN
GMCLCore/__pycache__/config.cpython-38.pyc
Executable file
BIN
GMCLCore/__pycache__/config.cpython-38.pyc
Executable file
Binary file not shown.
0
GMCLCore/__pycache__/gaming.cpython-37.pyc
Normal file → Executable file
0
GMCLCore/__pycache__/gaming.cpython-37.pyc
Normal file → Executable file
0
GMCLCore/__pycache__/log4py.cpython-37.pyc
Normal file → Executable file
0
GMCLCore/__pycache__/log4py.cpython-37.pyc
Normal file → Executable file
BIN
GMCLCore/__pycache__/log4py.cpython-38.pyc
Executable file
BIN
GMCLCore/__pycache__/log4py.cpython-38.pyc
Executable file
Binary file not shown.
0
GMCLCore/__pycache__/main.cpython-37.pyc
Normal file → Executable file
0
GMCLCore/__pycache__/main.cpython-37.pyc
Normal file → Executable file
BIN
GMCLCore/__pycache__/main.cpython-38.pyc
Executable file
BIN
GMCLCore/__pycache__/main.cpython-38.pyc
Executable file
Binary file not shown.
0
GMCLCore/config.py
Normal file → Executable file
0
GMCLCore/config.py
Normal file → Executable file
BIN
GMCLCore/libs/._log4py.py
Executable file
BIN
GMCLCore/libs/._log4py.py
Executable file
Binary file not shown.
BIN
GMCLCore/libs/__pycache__/ariaAdapter.cpython-38.pyc
Executable file
BIN
GMCLCore/libs/__pycache__/ariaAdapter.cpython-38.pyc
Executable file
Binary file not shown.
BIN
GMCLCore/libs/__pycache__/log4py.cpython-38.pyc
Executable file
BIN
GMCLCore/libs/__pycache__/log4py.cpython-38.pyc
Executable file
Binary file not shown.
13
GMCLCore/libs/ariaAdapter.py
Executable file
13
GMCLCore/libs/ariaAdapter.py
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
from asyncio import subprocess
|
||||||
|
from matplotlib.pyplot import subplot
|
||||||
|
|
||||||
|
|
||||||
|
import os, subprocess
|
||||||
|
|
||||||
|
class adapter(object):
|
||||||
|
def __init__(self, path : str):
|
||||||
|
if not os.path.exists(path):
|
||||||
|
raise FileNotFoundError
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
raise TypeError
|
||||||
|
self.__path = path
|
33
GMCLCore/log4py.py → GMCLCore/libs/log4py.py
Normal file → Executable file
33
GMCLCore/log4py.py → GMCLCore/libs/log4py.py
Normal file → Executable file
@ -20,13 +20,14 @@ class log(object):
|
|||||||
raise TypeError("Wrong type for param @workdir")
|
raise TypeError("Wrong type for param @workdir")
|
||||||
self.workdir = workdir
|
self.workdir = workdir
|
||||||
self.__logs = []
|
self.__logs = []
|
||||||
if os.path.exists("{}\\logs".format(workdir)) and os.path.isfile("{}\\logs".format(workdir)):
|
if os.path.exists(os.path.join(workdir, "logs")) and os.path.isdir(os.path.join(workdir, "logs")):
|
||||||
guard = Thread(target = self.__daemon)
|
daemon = Thread(target = self.__daemon, name = "log4py-daemon")
|
||||||
guard.start()
|
daemon.daemon = True
|
||||||
|
daemon.start()
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os.makedirs("{}\\logs".format(workdir), exist_ok = True)
|
os.makedirs(os.path.join(workdir, "logs"), exist_ok = True)
|
||||||
daemon = Thread(target = self.__daemon)
|
daemon = Thread(target = self.__daemon, name = "log4py-daemon")
|
||||||
daemon.daemon = True
|
daemon.daemon = True
|
||||||
daemon.start()
|
daemon.start()
|
||||||
except:
|
except:
|
||||||
@ -35,14 +36,14 @@ class log(object):
|
|||||||
'''
|
'''
|
||||||
Guard thread for recording logs and archiving.
|
Guard thread for recording logs and archiving.
|
||||||
'''
|
'''
|
||||||
workdir = "{}\\logs".format(self.workdir)
|
workdir = os.path.abspath(os.path.join(self.workdir, "logs"))
|
||||||
self.__suicide = False
|
self.__suicide = False
|
||||||
def archive(workdir):
|
def archive(workdir):
|
||||||
timeStamp = time.time()
|
timeStamp = time.time()
|
||||||
logsList = []
|
logsList = []
|
||||||
for fname in os.listdir(workdir):
|
for fname in os.listdir(workdir):
|
||||||
if os.path.isfile("{}\\{}".format(workdir, fname)):
|
if os.path.isfile(os.path.join(workdir, fname)):
|
||||||
logsList.append("{}\\{}".format(workdir, fname))
|
logsList.append(os.path.join(workdir, fname))
|
||||||
archiveList = []
|
archiveList = []
|
||||||
today = time.strftime("%Y-%m-%d", time.localtime(timeStamp))
|
today = time.strftime("%Y-%m-%d", time.localtime(timeStamp))
|
||||||
# yesterday = time.strftime("%Y-%m-%d", time.localtime(timeStamp - 86400))
|
# yesterday = time.strftime("%Y-%m-%d", time.localtime(timeStamp - 86400))
|
||||||
@ -53,29 +54,21 @@ class log(object):
|
|||||||
flag = True
|
flag = True
|
||||||
if flag:
|
if flag:
|
||||||
self.info("Archiving logs.")
|
self.info("Archiving logs.")
|
||||||
'''
|
|
||||||
#Archive all logs before today in a single zip file
|
|
||||||
os.makedirs("{}\\{}".format(workdir,yesterday),exist_ok=True)
|
|
||||||
for fname in archiveList:
|
|
||||||
shutil.move(fname,"{}\\{}".format(workdir,yesterday))
|
|
||||||
shutil.make_archive("{}\\{}".format(workdir,yesterday),"zip",workdir,yesterday)
|
|
||||||
shutil.rmtree("{}\\{}".format(workdir,yesterday))
|
|
||||||
'''
|
|
||||||
# Archive each log in independence zip file
|
# Archive each log in independence zip file
|
||||||
for fname in archiveList:
|
for fname in archiveList:
|
||||||
basename = os.path.basename(fname)
|
basename = os.path.basename(fname)
|
||||||
shutil.make_archive("{}\\{}".format(workdir, os.path.splitext(basename)[0]), "zip", workdir, basename)
|
shutil.make_archive(os.path.join(workdir, os.path.splitext(basename)[0]), "zip", workdir, basename)
|
||||||
try:
|
try:
|
||||||
os.remove("{}\\{}".format(workdir, basename))
|
os.remove(os.path.join(workdir, basename))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
Thread(target = archive, args = (workdir,)).start()
|
Thread(target = archive, args = (workdir,), name = "log4py-archive").start()
|
||||||
while True:
|
while True:
|
||||||
timeStamp = time.time()
|
timeStamp = time.time()
|
||||||
today = time.strftime("%Y-%m-%d", time.localtime(timeStamp))
|
today = time.strftime("%Y-%m-%d", time.localtime(timeStamp))
|
||||||
while True:
|
while True:
|
||||||
with open("{}\\{}.logs".format(workdir,today),"a+") as fb:
|
with open(os.path.join(workdir, "{}.logs".format(today)),"a+") as fb:
|
||||||
data, self.__logs = self.__logs, []
|
data, self.__logs = self.__logs, []
|
||||||
for log in data:
|
for log in data:
|
||||||
fb.write("[{}] [{}] {}\n".format(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(log[0])), log[1], log[2]))
|
fb.write("[{}] [{}] {}\n".format(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(log[0])), log[1], log[2]))
|
147
GMCLCore/main.py
Normal file → Executable file
147
GMCLCore/main.py
Normal file → Executable file
@ -14,23 +14,32 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Standard
|
# Standard
|
||||||
import os, platform, hashlib, requests
|
import os, platform, hashlib, requests, json, time
|
||||||
import urllib.request, urllib.parse
|
import urllib.request, urllib.parse
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
# Extend
|
# Extend
|
||||||
import psutil
|
import psutil
|
||||||
# Self
|
# Self
|
||||||
import GMCLCore.log4py as log4py
|
import GMCLCore.libs.log4py as log4py
|
||||||
|
import GMCLCore.libs.ariaAdapter as aria
|
||||||
from GMCLCore.config import *
|
from GMCLCore.config import *
|
||||||
|
|
||||||
class Core(object):
|
class Core(object):
|
||||||
|
|
||||||
# Define constant
|
# Define constant
|
||||||
|
|
||||||
|
# Debug logs output switcher
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
# Downloader Mode
|
||||||
ARIA = "ARIA"
|
ARIA = "ARIA"
|
||||||
|
|
||||||
|
# Source Mode
|
||||||
OFFICIAL = "OFFICIAL"
|
OFFICIAL = "OFFICIAL"
|
||||||
BMCLAPI = "BMCLAPI"
|
BMCLAPI = "BMCLAPI"
|
||||||
|
|
||||||
|
# Auth Mode
|
||||||
OFFLINE = "OFFLINE"
|
OFFLINE = "OFFLINE"
|
||||||
MOJANG = "MOJANG"
|
MOJANG = "MOJANG"
|
||||||
MICROSOFT = "MICROSOFT"
|
MICROSOFT = "MICROSOFT"
|
||||||
@ -59,7 +68,7 @@ class Core(object):
|
|||||||
|
|
||||||
# Define default game vars
|
# Define default game vars
|
||||||
self.gameDir = os.path.join(os.path.dirname(__file__), ".minecraft")
|
self.gameDir = os.path.join(os.path.dirname(__file__), ".minecraft")
|
||||||
self.javaPath = self.searchJava()
|
self.java = [[], None]
|
||||||
self.gameMem = self.autoMemory()
|
self.gameMem = self.autoMemory()
|
||||||
self.authType = self.OFFLINE
|
self.authType = self.OFFLINE
|
||||||
self.id = "Steve"
|
self.id = "Steve"
|
||||||
@ -67,16 +76,19 @@ class Core(object):
|
|||||||
|
|
||||||
# Prepare running env
|
# Prepare running env
|
||||||
self.l.info("Initing running env...")
|
self.l.info("Initing running env...")
|
||||||
|
os.makedirs(os.path.join(self.__workDir, "env"), exist_ok = True)
|
||||||
|
os.makedirs(os.path.join(self.__workDir, "config"), exist_ok = True)
|
||||||
self.initEnv()
|
self.initEnv()
|
||||||
|
|
||||||
# Create daemon thread
|
# Create daemon thread
|
||||||
self.l.info("Creating daemon thread...")
|
self.l.info("Creating daemon thread...")
|
||||||
self.__daemonThread = Thread(target = self.__daemon)
|
self.__daemonThread = Thread(target = self.__daemon, name = "Daemon")
|
||||||
self.__daemonThread.daemon = True
|
self.__daemonThread.daemon = True
|
||||||
self.__daemonThread.start()
|
self.__daemonThread.start()
|
||||||
|
|
||||||
|
# Prepare the launcher runnning env
|
||||||
def initEnv(self):
|
def initEnv(self):
|
||||||
os.makedirs(os.path.join(self.__workDir, "env"), exist_ok = True)
|
# Aria2c
|
||||||
if self.networkTest():
|
if self.networkTest():
|
||||||
source = self.urljoin(self.ENV_SOURCE, "aria2c")
|
source = self.urljoin(self.ENV_SOURCE, "aria2c")
|
||||||
if self.__system == "Windows":
|
if self.__system == "Windows":
|
||||||
@ -96,7 +108,7 @@ class Core(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.l.warn("Failed to install running env aria2c! System return: {}".format(e))
|
self.l.warn("Failed to install running env aria2c! System return: {}".format(e))
|
||||||
elif self.__system == "Linux":
|
elif self.__system == "Linux":
|
||||||
self.__ariaPath = self.urljoin(self.__workDir, "env", "aria2c")
|
self.__ariaPath = self.urljoin(self.__workDir, "env", "aria2clinux")
|
||||||
source = self.urljoin(source, "linux")
|
source = self.urljoin(source, "linux")
|
||||||
if not os.path.exists(self.__ariaPath):
|
if not os.path.exists(self.__ariaPath):
|
||||||
with open(self.__ariaPath, "wb") as fb:
|
with open(self.__ariaPath, "wb") as fb:
|
||||||
@ -106,7 +118,7 @@ class Core(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.l.warn("Failed to install running env aria2c! System return: {}".format(e))
|
self.l.warn("Failed to install running env aria2c! System return: {}".format(e))
|
||||||
elif self.__system == "Darwin":
|
elif self.__system == "Darwin":
|
||||||
self.__ariaPath = self.urljoin(self.__workDir, "env", "aria2c")
|
self.__ariaPath = self.urljoin(self.__workDir, "env", "aria2cdarwin")
|
||||||
source = self.urljoin(source, "darwin")
|
source = self.urljoin(source, "darwin")
|
||||||
if not os.path.exists(self.__ariaPath):
|
if not os.path.exists(self.__ariaPath):
|
||||||
with open(self.__ariaPath, "wb") as fb:
|
with open(self.__ariaPath, "wb") as fb:
|
||||||
@ -115,47 +127,124 @@ class Core(object):
|
|||||||
fb.write(content)
|
fb.write(content)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.l.warn("Failed to install running env aria2c! System return: {}".format(e))
|
self.l.warn("Failed to install running env aria2c! System return: {}".format(e))
|
||||||
|
try:
|
||||||
|
self.aria = aria.adapter(self.__ariaPath)
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
self.l.warn("Failed to find running env aria2c! System return: {}".format(e))
|
||||||
|
except TypeError as e:
|
||||||
|
self.l.warn("Failed to find running env aria2c! System return: {}".format(e))
|
||||||
|
else:
|
||||||
|
self.aria = False
|
||||||
|
|
||||||
|
# The daemon thread function
|
||||||
def __daemon(self):
|
def __daemon(self):
|
||||||
while True:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def urljoin(self, *args: str):
|
# Start some sub-daemon-thread
|
||||||
|
threadPool = []
|
||||||
|
for t in threadPool:
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
while True: ...
|
||||||
|
|
||||||
|
# Debug logs output
|
||||||
|
def __debug(self, *args) -> None :
|
||||||
|
self.l.info(*args)
|
||||||
|
|
||||||
|
# Determin wheather the @content is a legal json
|
||||||
|
def isJson(self, content: str) -> bool:
|
||||||
|
try:
|
||||||
|
json.loads(content)
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Merge the url
|
||||||
|
def urljoin(self, *args: str) -> str:
|
||||||
result = os.path.join(*args)
|
result = os.path.join(*args)
|
||||||
for i in range(result.count("\\")):
|
for _ in range(result.count("\\")):
|
||||||
result = result.replace("\\", "/")
|
result = result.replace("\\", "/")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def networkTest(self, source = r"https://www.baidu.com", retry = 3):
|
# Test the network working
|
||||||
|
def networkTest(self, source : str = r"http://www.baidu.com", retry : int = 3) -> bool:
|
||||||
flag = False
|
flag = False
|
||||||
for i in range(retry):
|
for _ in range(retry):
|
||||||
try:
|
try:
|
||||||
fp = urllib.request.urlopen(source)
|
fp = urllib.request.urlopen(source)
|
||||||
fp.read(100).decode()
|
fp.read(100).decode()
|
||||||
fp.close()
|
fp.close()
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
self.__debug("networkTest Error:", str(e))
|
||||||
else:
|
else:
|
||||||
flag = True
|
flag = True
|
||||||
|
break
|
||||||
return flag
|
return flag
|
||||||
|
|
||||||
|
# Scan java in the Path and whole disk
|
||||||
|
def searchJava(self) -> None:
|
||||||
|
keywords = ("javaw", "java", "javaw.exe", "java.exe")
|
||||||
|
# Search in Env Vars
|
||||||
|
def env() -> None :
|
||||||
|
while True:
|
||||||
|
javaEnv = os.environ.get("Path", None) if self.__system == "Windows" else os.environ.get("PATH", None)
|
||||||
|
if javaEnv:
|
||||||
|
javaEnv = javaEnv.split(";") if self.__system == "Windows" else javaEnv.split(":")
|
||||||
|
for j in javaEnv:
|
||||||
|
for name in keywords:
|
||||||
|
if name == os.path.basename(j) and "jdk" not in j:
|
||||||
|
if os.path.exists(j):
|
||||||
|
version = self.javaVersion(j)
|
||||||
|
if not version:
|
||||||
|
self.java[0].append((j, version))
|
||||||
|
time.sleep(0.5)
|
||||||
|
# Scan in whole disk
|
||||||
|
def disk() -> None:
|
||||||
|
while True:
|
||||||
|
disks = []
|
||||||
|
if self.__system == "Windows":
|
||||||
|
partitions = psutil.disk_partitions()
|
||||||
|
for p in partitions:
|
||||||
|
disks.append(p.mountpoint)
|
||||||
|
else:
|
||||||
|
disks.append("/")
|
||||||
|
for d in disks:
|
||||||
|
for root, _, file in os.walk(d):
|
||||||
|
for f in file:
|
||||||
|
filePath = os.path.join(root, f)
|
||||||
|
for name in keywords:
|
||||||
|
if name == os.path.basename(filePath) and "jdk" not in filePath:
|
||||||
|
if os.path.exists(filePath):
|
||||||
|
version = self.javaVersion(filePath)
|
||||||
|
if not version:
|
||||||
|
self.java[0].append((filePath, version))
|
||||||
|
time.sleep(0.5)
|
||||||
|
envThread = Thread(target = env, name = "scanJavaEnv")
|
||||||
|
diskThread = Thread(target = disk, name = "scanJavaDisk")
|
||||||
|
envThread.daemon = True
|
||||||
|
diskThread.daemon = True
|
||||||
|
envThread.start()
|
||||||
|
diskThread.start()
|
||||||
|
|
||||||
def searchJava(self):
|
# Read the version of the java
|
||||||
javaEnv = os.environ.get("Path", None) if self.__system == "Windows" else os.environ.get("PATH", None)
|
def javaVersion(self, path : str):
|
||||||
if javaEnv:
|
p = Popen((path, "--version"), shell = True, stdout = PIPE)
|
||||||
javaEnv = javaEnv.split(";") if self.__system == "Windows" else javaEnv.split(":")
|
out = p.communicate()[0]
|
||||||
for j in javaEnv:
|
try:
|
||||||
for name in ("Java", "java", "JAVA", "Jre", "jre", "JRE"):
|
result = int(out.splitlines()[0].decode().split()[1].split(".")[0])
|
||||||
if name in j:
|
except (UnicodeDecodeError, ValueError):
|
||||||
java = j
|
return False
|
||||||
merge = os.path.join(java, "javaw.exe" if self.__system == "Windows" else "java")
|
else:
|
||||||
if os.path.exists(merge):
|
return result
|
||||||
return merge
|
|
||||||
|
|
||||||
def autoMemory(self):
|
# Return a auto-determined memory value for game
|
||||||
|
def autoMemory(self) -> float:
|
||||||
return 0.8 * (psutil.virtual_memory().free / 1024 ** 2)
|
return 0.8 * (psutil.virtual_memory().free / 1024 ** 2)
|
||||||
|
|
||||||
def generateUUID(self, id):
|
# Generate a offline player UUID
|
||||||
|
def generateUUID(self, id : str) -> str:
|
||||||
result = hashlib.md5()
|
result = hashlib.md5()
|
||||||
result.update("".join(('OfflinePlayer:', id)).encode())
|
result.update("".join(('OfflinePlayer:', id)).encode())
|
||||||
result = result.hexdigest()
|
result = result.hexdigest()
|
||||||
return result
|
return result
|
||||||
|
7
Test.py
Normal file → Executable file
7
Test.py
Normal file → Executable file
@ -1,5 +1,8 @@
|
|||||||
|
|
||||||
import platform, subprocess, urllib.parse, os, requests
|
import platform, subprocess, urllib.parse, os, requests, asyncio, time
|
||||||
import GMCLCore
|
import GMCLCore
|
||||||
|
|
||||||
Core = GMCLCore.Core()
|
Core = GMCLCore.Core()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
exec(input())
|
0
icon.ico
Normal file → Executable file
0
icon.ico
Normal file → Executable file
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
0
old/0.1.0/config.json
Normal file → Executable file
0
old/0.1.0/config.json
Normal file → Executable file
0
old/0.1.0/gmclc.py
Normal file → Executable file
0
old/0.1.0/gmclc.py
Normal file → Executable file
0
old/other/GMCLCore.py
Normal file → Executable file
0
old/other/GMCLCore.py
Normal file → Executable file
0
old/other/requirement.txt
Normal file → Executable file
0
old/other/requirement.txt
Normal file → Executable file
3
requirement.txt
Executable file
3
requirement.txt
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
psutil
|
||||||
|
tencentcloud-sdk-python
|
||||||
|
pywin32; platform_system == "Windows"
|
Reference in New Issue
Block a user