On 10.03.06 04:29:25, Tina Isaksen wrote:
> Andreas Pakulat wrote:
>
> >>I gave up. I just could not get a QProcess write to a process stdin.
> >>
> >
> >I'll see if I can write up a small example to test this. Maybe you just
> >hit a bug...
> >
> Great. I'm very interested in why I failed to make it work.
Here you go, the attached program works for me, after 5 seconds apt-get
correctly gets the "y". Note that the "\n" after it is needed, because
else apt doesn't get that this is all you want to send.
Andreas
--
You are a very redundant person, that's what kind of person you are.
# -*- coding: utf-8 -*-
from qt import *
import sys
class test(QObject):
def __init__(self):
QObject.__init__(self)
self.p = QProcess()
self.connect(self.p, SIGNAL("readyReadStdout()"), self.readOut)
self.connect(self.p, SIGNAL("processExited()"), self.procEx)
self.connect(self.p, SIGNAL("readyReadStderr()"), self.readErr)
self.p.setArguments(QStringList.split(" ", "apt-get upgrade"))
self.p.start()
QTimer.singleShot(5000, self.writeStdIn)
def readOut(self):
print "Readout"
s = QString(self.p.readStdout()).ascii()
print s
def readErr(self):
print "ReadErr"
s = QString(self.p.readStderr()).ascii()
print s
def writeStdIn(self):
print "writing to stdin"
self.p.writeToStdin("Y\n")
def procEx(self):
qApp.exit();
def main(args):
app = QApplication(args)
t = test()
app.exec_loop()
if __name__ == "__main__":
sys.exit(main(sys.argv))
_______________________________________________
PyKDE mailing list [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde