From b1e457f5405209f58c75d67bf90aaa28883cbbe5 Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Sat, 2 Dec 2023 13:22:43 +0100 Subject: [PATCH] improve os name detection --- custom_components/easy_computer_manage/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/custom_components/easy_computer_manage/utils.py b/custom_components/easy_computer_manage/utils.py index 5be4b5f..566cc22 100644 --- a/custom_components/easy_computer_manage/utils.py +++ b/custom_components/easy_computer_manage/utils.py @@ -48,9 +48,14 @@ def get_operating_system_version(connection: Connection, is_unix=None): is_unix = is_unix_system(connection) if is_unix: - return connection.run( - "lsb_release -a | awk '/Description/ {print $2, $3, $4}'" - ).stdout + result = connection.run( + "awk -F'=' '/^NAME=|^VERSION=/{gsub(/\"/, \"\", $2); printf $2\" \"}\' /etc/os-release && echo").stdout + if result == "": + result = connection.run( + "lsb_release -a | awk '/Description/ {print $2, $3, $4}'" + ).stdout + + return result else: return connection.run( 'for /f "tokens=1 delims=|" %i in (\'wmic os get Name ^| findstr /B /C:"Microsoft"\') do @echo %i'