From 723eea1d40b110b299a9844672eb6defd0caa982 Mon Sep 17 00:00:00 2001 From: Caohongtao Date: Tue, 7 Nov 2023 06:15:52 +0000 Subject: [PATCH] update build/builder/common/env_checker.py. Signed-off-by: Caohongtao --- build/builder/common/env_checker.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/build/builder/common/env_checker.py b/build/builder/common/env_checker.py index 3f904f3..b159aec 100755 --- a/build/builder/common/env_checker.py +++ b/build/builder/common/env_checker.py @@ -30,12 +30,17 @@ class Checker: return cls._instance def __init__(self): - with open('/etc/os-release', 'r') as f: - for line in f: - if line.startswith('ID='): - self.os_id = line.split('=')[1].strip().strip('"').lower() - elif line.startswith('VERSION_ID='): - self.os_version = line.split('=')[1].strip().strip('"') + try: + with open('/etc/os-release', 'r') as f: + for line in f: + if line.startswith('ID='): + self.os_id = line.split('=')[1].strip().strip('"').lower() + elif line.startswith('VERSION_ID='): + self.os_version = line.split('=')[1].strip().strip('"') + except IOError: + logger.error('File: /etc/os-release not found') + self.os_id = None + self.os_version=None def _is_package_installed(self, pkg: str) -> bool: is_success, output = exec_sys_command(['rpm', '-q', pkg], is_show_output=False) -- Gitee