Add prototype helper (linux only)

This commit is contained in:
Zedifus 2022-06-20 18:05:39 +01:00
parent fd162a0d24
commit e820ba058a
2 changed files with 16 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import html
import zipfile import zipfile
import pathlib import pathlib
import ctypes import ctypes
import subprocess
from datetime import datetime from datetime import datetime
from socket import gethostname from socket import gethostname
from contextlib import redirect_stderr, suppress from contextlib import redirect_stderr, suppress
@ -81,6 +82,20 @@ class Helpers:
print(f"Import Error: Unable to load {ex.name} module") print(f"Import Error: Unable to load {ex.name} module")
installer.do_install() installer.do_install()
@staticmethod
def find_java_installs():
try:
paths = subprocess.check_output(
["/usr/bin/update-alternatives", "--list", "java"], encoding="utf8"
)
if re.match("^(/[^/ ]*)+/?$", paths):
return paths.split("\n")
except Exception as e:
print("Java Detect Error: ", e)
logger.error(f"Java Detect Error: {e}")
@staticmethod @staticmethod
def float_to_string(gbs: float): def float_to_string(gbs: float):
s = str(float(gbs) * 1000).rstrip("0").rstrip(".") s = str(float(gbs) * 1000).rstrip("0").rstrip(".")

View File

@ -224,6 +224,7 @@ if __name__ == "__main__":
controller_setup_thread.join() controller_setup_thread.join()
Console.info("Crafty has fully started and is now ready for use!") Console.info("Crafty has fully started and is now ready for use!")
console.debug(helper.find_java_installs())
crafty_prompt.prompt = f"Crafty Controller v{helper.get_version_string()} > " crafty_prompt.prompt = f"Crafty Controller v{helper.get_version_string()} > "
if not args.daemon: if not args.daemon: