Skip to content

Commit f380aae

Browse files
committed
Remove os.system
Signed-off-by: maipbui <[email protected]>
1 parent 83d60d5 commit f380aae

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

device/juniper/x86_64-juniper_qfx5200-r0/plugins/qfx5200_eeprom_data.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
# as noted in the Third-Party source code file.
3434

3535
import os
36+
import shutil
3637
import binascii
3738
import subprocess
3839
from sonic_eeprom import eeprom_tlvinfo
@@ -170,20 +171,17 @@ def main():
170171
eeprom_file.write("Main board eeprom (0x57)\r\n")
171172
eeprom_file.write("===============================\r\n")
172173

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

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

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

device/juniper/x86_64-juniper_qfx5210-r0/plugins/qfx5210_eeprom_data.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,10 @@ def main():
8282
eeprom_file.write("Manufacture Name=%s\r\n" % eeprom_qfx5210.manufacture_name_str())
8383

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

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

0 commit comments

Comments
 (0)