[Edgecore][device/accton] Fix subprocess.call issue in is_host(). (#13111)

Signed-off-by: roger530-ho <roger530_ho@edge-core.com>
This commit is contained in:
roger530-ho 2022-12-21 05:13:42 +08:00 committed by GitHub
parent e83aa15f30
commit 3740f1efb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 12 deletions

View File

@ -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 = ""
@ -14,7 +14,11 @@ class APIHelper():
(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

View File

@ -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 = ""
@ -14,7 +14,11 @@ class APIHelper():
(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

View File

@ -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 = ""
@ -14,7 +14,11 @@ class APIHelper():
(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

View File

@ -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 = ""
@ -14,7 +14,11 @@ class APIHelper():
(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

View File

@ -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 = ""
@ -14,7 +14,11 @@ class APIHelper():
(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

View File

@ -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 = ""
@ -14,7 +14,11 @@ class APIHelper():
(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