[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:
Volodymyr Boiko 2021-01-30 03:29:37 +02:00 committed by GitHub
parent 284c2738e8
commit 481870670d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,7 @@ try:
from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
from .platform_thrift_client import thrift_try
from platform_thrift_client import thrift_try
except ImportError as e:
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_STATUS = "/var/run/platform/eeprom/status"
try:
_str_type = basestring
except NameError:
_str_type = str
class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
def __init__(self):
@ -101,7 +106,7 @@ class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
f.close()
eeprom_params = ""
for attr, val in self.eeprom.__dict__.iteritems():
for attr, val in self.eeprom.__dict__.items():
if val is None:
continue
@ -109,7 +114,7 @@ class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
if elem is None:
continue
if isinstance(val, basestring):
if isinstance(val, _str_type):
value = val.replace('\0', '')
else:
value = str(val)