In the following case, I am trying to print all output of temp2 script (which is run through subprocess) on to a textbox widget in realtime basis.
The problem I am facing is this, in temp2, for i <= 468
, the script is working fine and to me it appears to be real time.
However, if i put i = 469
or above, the execution halts after many iterations without finishing.
So for example, for i = 469
, the log file has entries for i = 469
to i = 3
. There after the whole process halts.
Please note: the value i = 469
may not be the same for your machine. If i = 469
works fine for you, try some higher value.
Temp1.py is the main script.
#temp1.py
from Tkinter import *
import Tkinter as tk
import os
import ttk
os.system('echo OS ready')
os.system('chmod 755 *')
import subprocess
import sys
#Creating new Window to display output
t = Tk()
t.title('output Run Display')
t.geometry('800x1000-5+40')
t.state('normal')
little = Label(t, text="NRUNTEST OUTPUT LOG").grid(column = 0, row = 0)
log = Text(t, state='disabled', width=115, height=150, wrap='none')
log.grid(row = 1, column = 0)
test=subprocess.Popen('temp2',shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
#stdout
while True:
line_out = test.stdout.readline()
line_er = test.stderr.readline()
if line_out == "" and line_er == "":
break
else:
log['state'] = 'normal'
log.insert('end', line_out)
log.insert('end', line_er)
log['state'] = 'disabled'
print line_out
print line_er
t.update()
t.mainloop()
And below is the script i am running through the subprocess.
#temp2 #csh script
set i = 469
while ($i > 0)
echo i is $i | tee -a log
set i = `expr "$i" - 1`
end