commit
397486253b
|
@ -17,53 +17,44 @@ disk = ""
|
||||||
lists = []
|
lists = []
|
||||||
|
|
||||||
|
|
||||||
def version_check(file_json, pkg_name):
|
def __version_parse(version: str) -> list:
|
||||||
try:
|
return [int(i) for i in version.split(".")]
|
||||||
if "compatibility" in file_json:
|
|
||||||
if "injector" in file_json["compatibility"]:
|
|
||||||
with open(f"{disk}/PEinjector/VERSION", "r", encoding="utf-8") as file:
|
|
||||||
version = file.readlines()[0].rstrip("\n\r")
|
|
||||||
if "min" in file_json["compatibility"]["injector"]:
|
|
||||||
plugver = file_json["compatibility"]["injector"]["min"]
|
|
||||||
|
|
||||||
def vererr():
|
|
||||||
log.warn(f"load moudle [{pkg_name}] failed: " +
|
|
||||||
f"PEinjector version too low, need [{plugver}]")
|
|
||||||
if int(plugver.split(".")[0]) > int(version.split(".")[0]):
|
|
||||||
vererr()
|
|
||||||
return 5
|
|
||||||
elif int(plugver.split(".")[0]) == int(version.split(".")[0]):
|
|
||||||
if plugver.split(".")[1] > version.split(".")[1]:
|
|
||||||
vererr()
|
|
||||||
return 5
|
|
||||||
elif int(plugver.split(".")[1]) == int(version.split(".")[1]):
|
|
||||||
if int(plugver.split(".")[2]) > int(version.split(".")[2]):
|
|
||||||
vererr()
|
|
||||||
return 5
|
|
||||||
if "max" in file_json["compatibility"]["injector"]:
|
|
||||||
plugver = file_json["compatibility"]["injector"]["max"]
|
|
||||||
|
|
||||||
def vererr():
|
def __version_compare(ver1: str, ver2: str) -> int:
|
||||||
log.warn(f"load moudle [{pkg_name}] failed: " +
|
version1 = __version_parse(ver1)
|
||||||
f"PEinjector version too high, need [{plugver}]")
|
version2 = __version_parse(ver2)
|
||||||
if int(plugver.split(".")[0]) < int(version.split(".")[0]):
|
for (i, j) in zip(version1, version2):
|
||||||
vererr()
|
if i != j:
|
||||||
return 6
|
return 1 if i > j else -1
|
||||||
elif int(plugver.split(".")[0]) == int(version.split(".")[0]):
|
|
||||||
if int(plugver.split(".")[1] < version.split(".")[1]):
|
|
||||||
vererr()
|
|
||||||
return 6
|
|
||||||
elif plugver.split(".")[1] == version.split(".")[1]:
|
|
||||||
if int(plugver.split(".")[2] < version.split(".")[2]):
|
|
||||||
vererr()
|
|
||||||
return 6
|
|
||||||
except:
|
|
||||||
log.warn(f"load moudle [{pkg_name}] failed: " +
|
|
||||||
"The version number is formatted incorrectly")
|
|
||||||
return 7
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def version_check(configuration: dict, pkg_name: str) -> int:
|
||||||
|
ERROR_MESSAGE = "load moudle [{}] failed: PEinjector version too {}, need [{}]"
|
||||||
|
try:
|
||||||
|
if not "compatibility" in configuration or not "injector" in configuration["compatibility"]:
|
||||||
|
return 0
|
||||||
|
with open(f"{disk}/PEinjector/VERSION", 'r', encoding="utf-8") as f:
|
||||||
|
version = f.readlines()[0].rstrip("\n\r")
|
||||||
|
|
||||||
|
if "min" in configuration["compatibility"]["injector"]:
|
||||||
|
plugver = configuration["compatibility"]["injector"]["min"]
|
||||||
|
if __version_compare(version, plugver) == -1:
|
||||||
|
log.warn(ERROR_MESSAGE.format(pkg_name, "low", plugver))
|
||||||
|
return 5
|
||||||
|
|
||||||
|
if "max" in configuration["compatibility"]["injector"]:
|
||||||
|
plugver = configuration["compatibility"]["injector"]["max"]
|
||||||
|
if __version_compare(version, plugver) == 1:
|
||||||
|
log.warn(ERROR_MESSAGE.format(pkg_name, "high", plugver))
|
||||||
|
return 6
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
log.warn(f"load moudle [{pkg_name}] failed: {e}")
|
||||||
|
return 7
|
||||||
|
|
||||||
|
|
||||||
def file_check(file_json, pkg_name):
|
def file_check(file_json, pkg_name):
|
||||||
try:
|
try:
|
||||||
if "compatibility" in file_json:
|
if "compatibility" in file_json:
|
||||||
|
|
Loading…
Reference in New Issue