I have a method that creates a subprocess and binds its STDIN to an anonymous channel; which does not work. Without throwing any exceptions, the subprocess simply never reads the data. (the subprocess is the zenity executable to display the progress bar in the graphical interface)
class Screen(object):
def __init__(self, display = ":0", bin = '/usr/bin/zenity'):
self.bin = bin
os.environ['DISPLAY'] = display
self.dis = display
def displayProgress(self, text, pulse = True, title = 'Progess'):
'''Method to represent the 'zenity --progress' command
'''
readp, writep = os.pipe()
reade, writee = os.pipe()
rfd = os.fdopen(readp, 'r')
wfd = os.fdopen(writep, 'w')
if pulse:
zenhandle = Popen([self.bin, '--progress',
'--title=%s' % title,
'--auto-close',
'--pulsate'],
stdin = rfd)
else:
zenhandle = Popen([self.bin, '--progress',
'--title=%s' % title,
'--auto-close'],
stdin = rfd)
self.progress = wfd
The idea of calling a method will be non-blocking, and I can do write()before Screen.progressand should be written to the STDIN of the child (zenity) process. (zenity draws a filling graph by reading values from STDIN)
The box is displayed on the screen, but Screen.progress.write('50')never updates the panel.
What am I doing wrong?
Edit:
, python, . (). , -- python.