Skip to content

Commit

Permalink
[Edgecore][device/accton] Fix subprocess.call issue in is_host(). (#1…
Browse files Browse the repository at this point in the history
…3111)

Signed-off-by: roger530-ho <[email protected]>
  • Loading branch information
roger530-ho authored Dec 20, 2022
1 parent e83aa15 commit 3740f1e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import struct
import subprocess
from mmap import *
from sonic_py_common import device_info
from sonic_py_common.general import getstatusoutput_noshell

HOST_CHK_CMD = ["docker"]
EMPTY_STRING = ""
Expand All @@ -14,7 +14,11 @@ def __init__(self):
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()

def is_host(self):
return subprocess.call(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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import struct
import subprocess
from mmap import *
from sonic_py_common import device_info
from sonic_py_common.general import getstatusoutput_noshell

HOST_CHK_CMD = ["docker"]
EMPTY_STRING = ""
Expand All @@ -14,7 +14,11 @@ def __init__(self):
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()

def is_host(self):
return subprocess.call(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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import struct
import subprocess
from mmap import *
from sonic_py_common import device_info
from sonic_py_common.general import getstatusoutput_noshell

HOST_CHK_CMD = ["docker"]
EMPTY_STRING = ""
Expand All @@ -14,7 +14,11 @@ def __init__(self):
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()

def is_host(self):
return subprocess.call(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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import struct
import subprocess
from mmap import *
from sonic_py_common import device_info
from sonic_py_common.general import getstatusoutput_noshell

HOST_CHK_CMD = ["docker"]
EMPTY_STRING = ""
Expand All @@ -14,7 +14,11 @@ def __init__(self):
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()

def is_host(self):
return subprocess.call(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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import struct
import subprocess
from mmap import *
from sonic_py_common import device_info
from sonic_py_common.general import getstatusoutput_noshell

HOST_CHK_CMD = ["docker"]
EMPTY_STRING = ""
Expand All @@ -14,7 +14,11 @@ def __init__(self):
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()

def is_host(self):
return subprocess.call(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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import struct
import subprocess
from mmap import *
from sonic_py_common import device_info
from sonic_py_common.general import getstatusoutput_noshell

HOST_CHK_CMD = ["docker"]
EMPTY_STRING = ""
Expand All @@ -14,7 +14,11 @@ def __init__(self):
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()

def is_host(self):
return subprocess.call(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 3740f1e

Please sign in to comment.