Fix java whereis and enhance architecture detection
This commit is contained in:
parent
a96ebe05aa
commit
90c01b8a8d
@ -22,20 +22,6 @@ if lv["osName"] == "":
|
||||
if lv["osVersion"] == "":
|
||||
lv["osVersion"] = platform.version()
|
||||
|
||||
print(colored(colorama.Fore.GREEN,"Checking for Java..."))
|
||||
global javaExe
|
||||
javaExe = shutil.which(lv["java"])
|
||||
if javaExe == None:
|
||||
print(colored(colorama.Fore.RED,"Java wasn't found at '" +lv["java"]+ "'. Please configure java in config.ini."))
|
||||
sys.exit(1)
|
||||
|
||||
if lv["jvmArch"] == "":
|
||||
print(colored(colorama.Fore.GREEN,"Querying JVM architecture..."))
|
||||
if "64-Bit" in subprocess.check_output([javaExe,"-version"]).decode("utf-8"):
|
||||
lv["jvmArch"] = "amd64"
|
||||
else:
|
||||
lv["jvmArch"] = "x86"
|
||||
|
||||
print("")
|
||||
for setting in lv:
|
||||
print(colored(colorama.Fore.BLACK,setting+ "=" +str(lv[setting])))
|
||||
@ -54,6 +40,40 @@ if not lv["osName"] in ["windows","linux","macos"]:
|
||||
print(colored(colorama.Fore.MAGENTA,"Falling back to assuming Linux."))
|
||||
lv["osName"] = "linux"
|
||||
|
||||
print(colored(colorama.Fore.GREEN,"Checking for Java..."))
|
||||
global javaExe
|
||||
javaExe = whereis(lv["java"])
|
||||
if javaExe == None:
|
||||
print(colored(colorama.Fore.RED,"Java wasn't found at '" +lv["java"]+ "'. Please configure java in config.ini."))
|
||||
sys.exit(1)
|
||||
|
||||
if lv["jvmArch"] == "":
|
||||
print(colored(colorama.Fore.GREEN,"Querying JVM architecture... "),end="")
|
||||
try:
|
||||
if lv["osName"] != "windows":
|
||||
with open(javaExe,"rb") as jh:
|
||||
jh.seek(4)
|
||||
if int.from_bytes(jh.read(1),"little") == 1:
|
||||
lv["jvmArch"] = "x86"
|
||||
print("x86")
|
||||
else:
|
||||
lv["jvmArch"] = "amd64"
|
||||
print("Not x86, assuming amd64")
|
||||
else:
|
||||
with open(javaExe,"rb") as jh:
|
||||
jh.seek(60)
|
||||
jh.seek(int.from_bytes(jh.read(2),"little") + 4)
|
||||
if int.from_bytes(jh.read(2),"little") == 332:
|
||||
lv["jvmArch"] = "x86"
|
||||
print("x86")
|
||||
else:
|
||||
lv["jvmArch"] = "amd64"
|
||||
print("Not x86, assuming amd64")
|
||||
except:
|
||||
print(colored(colorama.Fore.YELLOW,"\nWarning, could not query JVM architecture. Needs to be either amd64 or x86. Define it with jvmArch=arch in the config."),file=sys.stderr)
|
||||
print(colored(colorama.Fore.MAGENTA,"Assuming amd64."))
|
||||
raise
|
||||
|
||||
print("")
|
||||
if not "version" in lv: lv["version"] = input("Version ID: ")
|
||||
if "-downloadonly" in sys.argv: lv["name"] = "Player"
|
||||
|
Loading…
Reference in New Issue
Block a user