From 5bc81766913f33339ac9d5bd7c3b07cc2d5d85a4 Mon Sep 17 00:00:00 2001 From: s-cu-bot <112623443+s-cu-bot@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:41:26 +0900 Subject: [PATCH] Fix printing windows version (#179) Signed-off-by: s-cu-bot --- src/fosslight_util/set_log.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/fosslight_util/set_log.py b/src/fosslight_util/set_log.py index 47fa8d9..9c3dd76 100755 --- a/src/fosslight_util/set_log.py +++ b/src/fosslight_util/set_log.py @@ -34,6 +34,21 @@ def init_check_latest_version(pkg_version="", main_package_name=""): logger.debug('Cannot check the latest version:' + str(error)) +def get_os_version(): + + logger = logging.getLogger(constant.LOGGER_NAME) + + os_version = platform.system() + " " + platform.release() + if os_version == "Windows 10": + try: + windows_build = sys.getwindowsversion().build + if windows_build >= 22000: + os_version = "Windows 11" + except Exception as error: + logger.debug(str(error)) + return os_version + + class CustomAdapter(logging.LoggerAdapter): def __init__(self, logger, extra): super(CustomAdapter, self).__init__(logger, {}) @@ -72,7 +87,7 @@ def init_log(log_file: str, create_file: bool = True, stream_log_level: int = lo _result_log = { "Tool Info": main_package_name, "Python version": _PYTHON_VERSION, - "OS": platform.system()+" "+platform.release(), + "OS": get_os_version(), } if main_package_name != "": pkg_info = main_package_name