Fix path issue with update-alternatives

Sometimes it can be in /sbin,
if it is we return `None` which broke upstream frontend.
Returning an empty list to resolve this.
This commit is contained in:
Zedifus 2022-06-24 02:28:05 +01:00
parent 81bc228e40
commit cf25249a9d

View File

@ -124,17 +124,24 @@ class Helpers:
# If we get here we're linux so we will use 'update-alternatives'
# (If distro does not have update-alternatives then manual input.)
# Sometimes u-a will be in /sbin on some distros (which is annoying.)
ua_path = "/usr/bin/update-alternatives"
if not os.path.exists(ua_path):
logger.warning("update-alternatives not found! Trying /sbin")
ua_path = "/usr/sbin/update-alternatives"
try:
paths = subprocess.check_output(
["/usr/bin/update-alternatives", "--list", "java"], encoding="utf8"
[ua_path, "--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}")
return []
@staticmethod
def float_to_string(gbs: float):
@ -511,7 +518,7 @@ class Helpers:
logger.critical(f"Unable to write to {self.root_dir} directory!")
sys.exit(1)
# ensure the log directory is there
# the log directory is there
try:
with suppress(FileExistsError):
os.makedirs(os.path.join(self.root_dir, "logs"))