Skip to content

Commit

Permalink
[Edgecore][device][platform] Sync PR-13111 with is_host() function.
Browse files Browse the repository at this point in the history
Signed-off-by: michael_shih <michael_shih@edge-core.com>
  • Loading branch information
ec-michael-shih committed Jan 18, 2023
1 parent 5a22788 commit 19d00af
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
from sonic_py_common import logger
from threading import Lock
from typing import cast
from sonic_py_common.general import getstatusoutput_noshell
from sonic_py_common.general import getstatusoutput_noshell_pipe

HOST_CHK_CMD = "which systemctl > /dev/null 2>&1"
HOST_CHK_CMD = ["docker"]
EMPTY_STRING = ""


Expand All @@ -19,7 +20,11 @@ def __init__(self):
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()

def is_host(self):
return os.system(HOST_CHK_CMD) == 0
try:
status, output = getstatusoutput_noshell(HOST_CHK_CMD)
return status == 0
except Exception:
return False

def pci_get_value(self, resource, offset):
status = True
Expand Down

0 comments on commit 19d00af

Please sign in to comment.