The task is to write a script that will automatically flash Intel network cards via nvmupdate64e. I tried to write a script, but it hangs on processing nvmupdate64e output.
My script:
nic_type = find_nic() # return nic [e810-True, v710-True] or False
nic_e810 = 'cd /root/nic/nic/e810/E810/Linux_x64; ./nvmupdate64e -f'
nic_v710 = 'cd /root/nic/nic/xvv710/Linux_x64; ./nvmupdate64e -f'
if nic_type[0] == True:
result = Popen(nic_e810, shell=True, stdout=subprocess.PIPE)
while True:
line = result.stdout.readline()
if not line:
break
print("line from file2:", line)
Output:
line from file2: b'\n'
line from file2: b'Intel(R) Ethernet NVM Update Tool\n'
line from file2: b'NVMUpdate version 1.39.20.2\n'
line from file2: b'Copyright(C) 2013 - 2022 Intel Corporation.\n'
line from file2: b'\n'
line from file2: b'\n'
line from file2: b'WARNING: To avoid damage to your device, do not stop the update or reboot or power off the system during this update.\n'
Original output from Linux
Intel(R) Ethernet NVM Update Tool
NVMUpdate version 1.39.20.2
Copyright(C) 2013 - 2022 Intel Corporation.
WARNING: To avoid damage to your device, do not stop the update or reboot or power off the system during this update.
Inventory in progress. Please wait [***.......]
Num Description Ver.(hex) DevId S:B Status
=== ================================== ============ ===== ====== ==============
01) Intel(R) Ethernet Network Adapter 2.48(2.30) 159B 00:024 Update
E810-XXV-2 available
Options: Adapter Index List (comma-separated), [A]ll, e[X]it
Enter selection:
I think that python cannot intercept the console output completely. nvmupdate64 stops several times during operation to process data. I don't know how to intercept this output for processing and then continue execution.
I tried add poll()
while p.poll() is None:
print (p.stdout.readline(1))
in while and received this output
b' '
b'['
b'.'
b'.'
b'.'
b'.'
b'.'
b'.'
b'.'
b'.'
b'.'
b'.'
b']'
b'\x08'
b'\x08'
b'\x08'
b'\x08'
b'\x08'
b'\x08'
b'\x08'
b'\x08'
b'\x08'
b'\x08'
b'\x08'
b'|'
b'\x08'
In original output that is [***.......]