From c93f0012daa327c1f65ebe725136cfe36dd6f539 Mon Sep 17 00:00:00 2001 From: Xichen96 Date: Fri, 8 Mar 2024 00:46:28 +0800 Subject: [PATCH] replace host check command in e1031 (#18279) --- .../x86_64-cel_e1031-r0/sonic_platform/common.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/common.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/common.py index 7d3b37e36597..0838f0cf0a2a 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/common.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/common.py @@ -24,7 +24,6 @@ class Common: SET_METHOD_IPMI = 'ipmitool' NULL_VAL = 'N/A' - HOST_CHK_CMD = ["docker"] REF_KEY = '$ref:' def __init__(self, conf=None): @@ -184,12 +183,13 @@ def write_txt_file(self, file_path, value): return False return True - def is_host(self): - try: - subprocess.call(self.HOST_CHK_CMD, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - except FileNotFoundError: - return False - return True + def is_host(): + """ + Test whether current process is running on the host or an docker + return True for host and False for docker + """ + docker_env_file = '/.dockerenv' + return os.path.exists(docker_env_file) is False def load_json_file(self, path): """