From 2e05cf15014a6902f26ee354f82c831e190ed62a Mon Sep 17 00:00:00 2001 From: Fierelier Date: Wed, 18 May 2022 15:03:42 +0200 Subject: [PATCH] Only check for java if -downloadonly isn't defined --- oml/stages/config.py | 67 ++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/oml/stages/config.py b/oml/stages/config.py index e94b077..6d27cf9 100644 --- a/oml/stages/config.py +++ b/oml/stages/config.py @@ -40,39 +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 +if not "-downloadonly" in sys.argv: + 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: ")