[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:
parent
e83aa15f30
commit
3740f1efb7
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
|
||||||
from mmap import *
|
from mmap import *
|
||||||
from sonic_py_common import device_info
|
from sonic_py_common import device_info
|
||||||
|
from sonic_py_common.general import getstatusoutput_noshell
|
||||||
|
|
||||||
HOST_CHK_CMD = ["docker"]
|
HOST_CHK_CMD = ["docker"]
|
||||||
EMPTY_STRING = ""
|
EMPTY_STRING = ""
|
||||||
@ -14,7 +14,11 @@ class APIHelper():
|
|||||||
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
||||||
|
|
||||||
def is_host(self):
|
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):
|
def pci_get_value(self, resource, offset):
|
||||||
status = True
|
status = True
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
|
||||||
from mmap import *
|
from mmap import *
|
||||||
from sonic_py_common import device_info
|
from sonic_py_common import device_info
|
||||||
|
from sonic_py_common.general import getstatusoutput_noshell
|
||||||
|
|
||||||
HOST_CHK_CMD = ["docker"]
|
HOST_CHK_CMD = ["docker"]
|
||||||
EMPTY_STRING = ""
|
EMPTY_STRING = ""
|
||||||
@ -14,7 +14,11 @@ class APIHelper():
|
|||||||
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
||||||
|
|
||||||
def is_host(self):
|
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):
|
def pci_get_value(self, resource, offset):
|
||||||
status = True
|
status = True
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
|
||||||
from mmap import *
|
from mmap import *
|
||||||
from sonic_py_common import device_info
|
from sonic_py_common import device_info
|
||||||
|
from sonic_py_common.general import getstatusoutput_noshell
|
||||||
|
|
||||||
HOST_CHK_CMD = ["docker"]
|
HOST_CHK_CMD = ["docker"]
|
||||||
EMPTY_STRING = ""
|
EMPTY_STRING = ""
|
||||||
@ -14,7 +14,11 @@ class APIHelper():
|
|||||||
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
||||||
|
|
||||||
def is_host(self):
|
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):
|
def pci_get_value(self, resource, offset):
|
||||||
status = True
|
status = True
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
|
||||||
from mmap import *
|
from mmap import *
|
||||||
from sonic_py_common import device_info
|
from sonic_py_common import device_info
|
||||||
|
from sonic_py_common.general import getstatusoutput_noshell
|
||||||
|
|
||||||
HOST_CHK_CMD = ["docker"]
|
HOST_CHK_CMD = ["docker"]
|
||||||
EMPTY_STRING = ""
|
EMPTY_STRING = ""
|
||||||
@ -14,7 +14,11 @@ class APIHelper():
|
|||||||
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
||||||
|
|
||||||
def is_host(self):
|
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):
|
def pci_get_value(self, resource, offset):
|
||||||
status = True
|
status = True
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
|
||||||
from mmap import *
|
from mmap import *
|
||||||
from sonic_py_common import device_info
|
from sonic_py_common import device_info
|
||||||
|
from sonic_py_common.general import getstatusoutput_noshell
|
||||||
|
|
||||||
HOST_CHK_CMD = ["docker"]
|
HOST_CHK_CMD = ["docker"]
|
||||||
EMPTY_STRING = ""
|
EMPTY_STRING = ""
|
||||||
@ -14,7 +14,11 @@ class APIHelper():
|
|||||||
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
||||||
|
|
||||||
def is_host(self):
|
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):
|
def pci_get_value(self, resource, offset):
|
||||||
status = True
|
status = True
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
|
||||||
from mmap import *
|
from mmap import *
|
||||||
from sonic_py_common import device_info
|
from sonic_py_common import device_info
|
||||||
|
from sonic_py_common.general import getstatusoutput_noshell
|
||||||
|
|
||||||
HOST_CHK_CMD = ["docker"]
|
HOST_CHK_CMD = ["docker"]
|
||||||
EMPTY_STRING = ""
|
EMPTY_STRING = ""
|
||||||
@ -14,7 +14,11 @@ class APIHelper():
|
|||||||
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
||||||
|
|
||||||
def is_host(self):
|
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):
|
def pci_get_value(self, resource, offset):
|
||||||
status = True
|
status = True
|
||||||
|
Loading…
Reference in New Issue
Block a user