Skip to content

Commit

Permalink
[barefoot][platform] platform API 2.0 fixes (#6607)
Browse files Browse the repository at this point in the history
To improve python3 support of berefoot's sonic_platform

Signed-off-by: Volodymyr Boyko <volodymyrx.boiko@intel.com>
  • Loading branch information
vboykox authored and lguohan committed Feb 3, 2021
1 parent 5fcb86f commit 3e70b97
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
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")

Expand Down Expand Up @@ -64,6 +64,11 @@
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):

Expand Down Expand Up @@ -101,15 +106,15 @@ def eeprom_parse(self):
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

elem = eeprom_default_dict.get(attr)
if elem is None:
continue

if isinstance(val, basestring):
if isinstance(val, _str_type):
value = val.replace('\0', '')
else:
value = str(val)
Expand Down

0 comments on commit 3e70b97

Please sign in to comment.