I'm trying to wait until some text is written to a live logfile in Python.
fdpexect would seem to be the right thing for this, but it isn't waiting. As soon as it hits the end of the file it terminates.
I'm wondering if fdpexpect just doesn't support this and I'll need to work around it?
The code I have is basically this:
Creating the spawn object:
# we're not using pexpect.spawn because we want
# all the output to be written to the logfile in real time,
# which spawn doesn't seem to support.
p = subprocess.Popen(command,
shell=shell,
stdout=spawnedLog.getFileObj(),
stderr=subprocess.STDOUT)
# give fdspawn the same file object we gave Popen
return (p, pexpect.fdpexpect.fdspawn(spawnedLog.getFileObj()))
Waiting for something:
pexpectObj.expect('something')
This basically quits immediately and before the 'something' event happens with an EOF error.