Merge branch 'bugfix/handle-none-java-return' into 'dev'

Fix path issue with update-alternatives

See merge request crafty-controller/crafty-4!387
This commit is contained in:
Iain Powrie 2022-06-24 03:01:13 +00:00
commit 4f40d79ee6
2 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,7 @@ None
- Fix cannot delete backup on page 2 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/382))
- Fix server starting up without stats monitoring after backup shutdown. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/386))
- Fix pathing issue when launching with just "java" ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/386))
- Fix path issue with update-alternatives ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/387))
### Tweaks
- Rework server list on status page display for use on small screens ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/383))
- Add clone server confirmation ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/384))

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):