Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Nokia]: EEPROM platform API Python3 compliance changes #6318

Merged
merged 1 commit into from
Dec 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _load_system_eeprom(self):
self.serial = 'NA'
return

total_length = (ord(eeprom[9]) << 8) | ord(eeprom[10])
total_length = (eeprom[9] << 8) | eeprom[10]
tlv_index = self._TLV_INFO_HDR_LEN
tlv_end = self._TLV_INFO_HDR_LEN + total_length

Expand All @@ -106,21 +106,16 @@ def _load_system_eeprom(self):
break

tlv = eeprom[tlv_index:tlv_index + 2
+ ord(eeprom[tlv_index + 1])]
code = "0x%02X" % (ord(tlv[0]))

if ord(tlv[0]) == self._TLV_CODE_VENDOR_EXT:
value = str((ord(tlv[2]) << 24) | (ord(tlv[3]) << 16) |
(ord(tlv[4]) << 8) | ord(tlv[5]))
value += str(tlv[6:6 + ord(tlv[1])])
else:
name, value = self.decoder(None, tlv)
+ eeprom[tlv_index + 1]]
code = "0x%02X" % (tlv[0])

name, value = self.decoder(None, tlv)

self.eeprom_tlv_dict[code] = value
if ord(eeprom[tlv_index]) == self._TLV_CODE_CRC_32:
if eeprom[tlv_index] == self._TLV_CODE_CRC_32:
break

tlv_index += ord(eeprom[tlv_index+1]) + 2
tlv_index += eeprom[tlv_index+1] + 2

self.base_mac = self.eeprom_tlv_dict.get(
"0x%X" % (self._TLV_CODE_MAC_BASE), 'NA')
Expand Down Expand Up @@ -181,7 +176,10 @@ def _get_eeprom_field(self, field_name):
for field in self.format:
field_end = field_start + field[2]
if field[0] == field_name:
return (True, self.eeprom_data[field_start:field_end])
if decode:
return (True, self.eeprom_data[field_start:field_end].decode('ascii'))
else:
return (True, self.eeprom_data[field_start:field_end])
field_start = field_end

return (False, None)
Expand Down