Fixing some python errors in the common PDDF platform classes (#10669)

This commit is contained in:
FuzailBrcm 2022-05-09 23:19:25 +05:30 committed by GitHub
parent b86499ccb9
commit 0ed671c9af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 51 deletions

View File

@ -21,7 +21,7 @@ import os
import shutil
import subprocess
import sys
from sonic_py_common import device_info
import pddfparse
PLATFORM_ROOT_PATH = '/usr/share/sonic/device'
@ -139,7 +139,7 @@ def driver_check():
def get_path_to_device():
# Get platform and hwsku
(platform, hwsku) = pddf_obj.get_platform_and_hwsku()
(platform, hwsku) = device_info.get_platform_and_hwsku()
# Load platform module from source
platform_path = "/".join([PLATFORM_ROOT_PATH, platform])

View File

@ -8,6 +8,7 @@ import subprocess
import sys
import time
import unicodedata
from sonic_py_common import device_info
bmc_cache = {}
cache = {}
@ -33,7 +34,7 @@ color_map = {
class PddfParse():
def __init__(self):
if not os.path.exists("/usr/share/sonic/platform"):
platform, hwsku = self.get_platform_and_hwsku()
platform, hwsku = device_info.get_platform_and_hwsku()
os.symlink("/usr/share/sonic/device/"+platform, "/usr/share/sonic/platform")
try:
@ -47,30 +48,6 @@ class PddfParse():
self.data_sysfs_obj = {}
self.sysfs_obj = {}
# Returns platform and HW SKU
def get_platform_and_hwsku(self):
try:
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
stdout=subprocess.PIPE,
shell=False,
universal_newlines=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
platform = stdout.rstrip('\n')
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY],
stdout=subprocess.PIPE,
shell=False,
universal_newlines=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
hwsku = stdout.rstrip('\n')
except OSError as e:
raise OSError("Cannot detect platform")
return (platform, hwsku)
###################################################################################################################
# GENERIC DEFS

View File

@ -6,6 +6,7 @@
try:
from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase
import time
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

View File

@ -13,6 +13,7 @@
try:
from sonic_platform_base.thermal_base import ThermalBase
import os
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

View File

@ -6,6 +6,7 @@ import re
import subprocess
import time
import unicodedata
from sonic_py_common import device_info
bmc_cache = {}
cache = {}
@ -31,7 +32,7 @@ color_map = {
class PddfApi():
def __init__(self):
if not os.path.exists("/usr/share/sonic/platform"):
self.platform, self.hwsku = self.get_platform_and_hwsku()
self.platform, self.hwsku = device_info.get_platform_and_hwsku()
os.symlink("/usr/share/sonic/device/"+self.platform, "/usr/share/sonic/platform")
try:
@ -44,29 +45,6 @@ class PddfApi():
self.data_sysfs_obj = {}
self.sysfs_obj = {}
# Returns platform and HW SKU
def get_platform_and_hwsku(self):
try:
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
stdout=subprocess.PIPE,
shell=False,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
platform = stdout.rstrip('\n')
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY],
stdout=subprocess.PIPE,
shell=False,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
hwsku = stdout.rstrip('\n')
except OSError as e:
raise OSError("Cannot detect platform")
return (platform, hwsku)
#################################################################################################################
# GENERIC DEFS
#################################################################################################################