Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -32,16 +32,12 @@
# components is subject to the terms and conditions of the respective license
# as noted in the Third-Party source code file.

import binascii
import os
import sys
import shutil
import binascii
import subprocess
from sonic_eeprom import eeprom_tlvinfo

if sys.version_info[0] < 3:
import commands
else:
import subprocess as commands


def fantype_detect():

Expand All @@ -56,9 +52,8 @@ def fantype_detect():
for filename in os.listdir(refpgaTMC_path):
if filename.endswith('_type'):
fantype_path = os.path.join(refpgaTMC_path, filename)
cat_string = "cat "
fantype_string = cat_string + fantype_path
status, fan_type = commands.getstatusoutput(fantype_string)
p = subprocess.run(["cat", fantype_path], capture_output=True, universal_newlines=True)
fan_type = p.stdout
if ((fan_type == AFO) or (fan_type == AFI)):
return fan_type
else:
Expand Down Expand Up @@ -176,20 +171,17 @@ def main():
eeprom_file.write("Main board eeprom (0x57)\r\n")
eeprom_file.write("===============================\r\n")

MainEepromCreate = 'sudo echo 24c02 0x57 > /sys/bus/i2c/devices/i2c-0/new_device'
MainEepromCreate = '24c02 0x57'
out_file = '/sys/bus/i2c/devices/i2c-0/new_device'
# Write the contents of Main Board EEPROM to file
try:
os.system(MainEepromCreate)
except OSError:
print('Error: Execution of "%s" failed', MainEepromCreate)
return False
f = open(out_file, 'w')
f.write(MainEepromCreate)
f.close()

MainEepromFileCmd = 'cat /sys/bus/i2c/devices/i2c-0/0-0057/eeprom > /etc/init.d/MainEeprom_qfx5200_ascii'
try:
os.system(MainEepromFileCmd)
except OSError:
print('Error: Execution of "%s" failed', MainEepromFileCmd)
return False
src_file = '/sys/bus/i2c/devices/i2c-0/0-0057/eeprom'
dst_file = '/etc/init.d/MainEeprom_qfx5200_ascii'
shutil.copy(src_file, dst_file)

maineeprom_ascii = '/etc/init.d/MainEeprom_qfx5200_ascii'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,10 @@ def main():
eeprom_file.write("Manufacture Name=%s\r\n" % eeprom_qfx5210.manufacture_name_str())

CPUeepromFileCmd = 'cat /sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-0056/eeprom > /etc/init.d/eeprom_qfx5210_ascii'
src_file = '/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-0056/eeprom'
dst_file = '/etc/init.d/eeprom_qfx5210_ascii'
# Write the contents of CPU EEPROM to file
try:
os.system(CPUeepromFileCmd)
except OSError:
print('Error: Execution of "%s" failed', CPUeepromFileCmd)
return False
shutil.copy(src_file, dst_file)

eeprom_ascii = '/etc/init.d/eeprom_qfx5210_ascii'
# Read file contents in Hex format
Expand Down