[barefoot][platform] platform API 2.0 fixes (#6607)
To improve python3 support of berefoot's sonic_platform Signed-off-by: Volodymyr Boyko <volodymyrx.boiko@intel.com>
This commit is contained in:
parent
5fcb86f770
commit
3e70b97342
@ -17,7 +17,7 @@ try:
|
|||||||
from sonic_eeprom import eeprom_base
|
from sonic_eeprom import eeprom_base
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
|
|
||||||
from .platform_thrift_client import thrift_try
|
from platform_thrift_client import thrift_try
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError (str(e) + "- required module not found")
|
raise ImportError (str(e) + "- required module not found")
|
||||||
|
|
||||||
@ -64,6 +64,11 @@ product_dict = { "Montara" : "Wedge100BF-32X-O-AC-F-BF",
|
|||||||
EEPROM_SYMLINK = "/var/run/platform/eeprom/syseeprom"
|
EEPROM_SYMLINK = "/var/run/platform/eeprom/syseeprom"
|
||||||
EEPROM_STATUS = "/var/run/platform/eeprom/status"
|
EEPROM_STATUS = "/var/run/platform/eeprom/status"
|
||||||
|
|
||||||
|
try:
|
||||||
|
_str_type = basestring
|
||||||
|
except NameError:
|
||||||
|
_str_type = str
|
||||||
|
|
||||||
class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
|
class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
@ -101,7 +106,7 @@ class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
eeprom_params = ""
|
eeprom_params = ""
|
||||||
for attr, val in self.eeprom.__dict__.iteritems():
|
for attr, val in self.eeprom.__dict__.items():
|
||||||
if val is None:
|
if val is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -109,7 +114,7 @@ class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
|
|||||||
if elem is None:
|
if elem is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(val, basestring):
|
if isinstance(val, _str_type):
|
||||||
value = val.replace('\0', '')
|
value = val.replace('\0', '')
|
||||||
else:
|
else:
|
||||||
value = str(val)
|
value = str(val)
|
||||||
|
Loading…
Reference in New Issue
Block a user