[PyKDE] QProcess: more guidance needed

Tina Isaksen tina at bestemselv.com
Wed Mar 8 07:58:07 GMT 2006

I wrote:

> Yes, I have already thought about that and it's indeed the language 
> that is the problem with that approach. So I was thinking that if I 
> could catch the process waiting for input I could pick up the question 
> (since I know what it asks for and what form it has. Like: "Do you 
> want to continue [Y/n]?" Then let an 'OK' button or something feed the 
> upper case letter to stdin).

Ok, so I managed to isolate the yes or no option regardless of language. 
But I can't seem to feed it correctly to the apt-get process. The code:

def readOutput(self):
        outputString = QString(self.upgradeProcess.readStdout())
        # Check if upgradeProcess ask to continue
        if outputString.endsWith("? "):
            # Isolate the yes/ no characters needed for input.
            yesOptionString = outputString.right(6)
            yesOption = yesOptionString.left(1)
            noOptionString = outputString.right(4)
            noOption = noOptionString.left(1)
            answer = yesOption # Temporary setting answer for testing. 
Will be replaced by user input.
            self.mainTextWindow.append(answer) # Temporary to verify answer
            # Feed answer to stdin
            if answer == yesOption:
                self.mainTextWindow.append("This is the yesOption!!") # 
Temporary just to verify that Y is isolated
                ## self.upgradeProcess.writeToStdin(chr(121)) #No difference
                self.mainTextWindow.append("This is the noOption!!") # 
Temporary  just to verify that Y is isolated
            ouputString = " "

I do feed 'something' that apt-get recieves because it aborts. It would 
not have done that unless it got a response of some sort. But even if I 
replace the 'yesOption' with the letter "y" it still just aborts. So I'm 
thinking that either I don't know how to properly write to stdin (a 
distinct posibility) or apt-get uses some other program/ process/ 
interface to handle user interaction.

I have tried looking for clues in apt's sourcecode but C++ is really not 
my cup of tea so I'm still stuck. And I'm running out of ideas...
So if anyone have an idea I'd really appreciate it.


Project: Tinapt
SVN repository:

More information about the PyQt mailing list