Fix issue of partially parsing syseeprom value (#10020) (#10276)

Why I did it
The current code assumes that the value part does not have whitespace. So everything after the whitespace will be ignored. The syseeprom values returned from platform API do not match the output of "show platform syseeprom" on dx010 and e1031 device.

How I did it
This change improved the regular expression for parsing syseeprom values to accommodate whitespaces in the value.
PR 10021 provides the solution, but committed to the wrong place for dx010 and e1031.

How to verify it
Compile the sonic_platform wheel for dx010, then upload to device and install the wheel, verify the platform eeprom API.

Signed-off-by: Eric Zhu <erzhu@celestica.com>
This commit is contained in:
Eric Zhu 2022-03-22 00:25:36 +08:00 committed by Qi Luo
parent 527232122e
commit 8a246b88b1
2 changed files with 2 additions and 2 deletions

View File

@ -45,7 +45,7 @@ class Tlv(eeprom_tlvinfo.TlvInfoDecoder):
for line in lines:
try:
match = re.search(
'(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', line)
'(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)(.*$)', line)
if match is not None:
idx = match.group(1)
value = match.group(3).rstrip('\0')

View File

@ -44,7 +44,7 @@ class Tlv(eeprom_tlvinfo.TlvInfoDecoder):
for line in lines:
try:
match = re.search(
'(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', line)
'(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)(.*$)', line)
if match is not None:
idx = match.group(1)
value = match.group(3).rstrip('\0')