Answer the question
In order to leave comments, you need to log in
How to get stdout in realtime and not at the end of command processing (python3 pyqt/pyside subprocess)?
I am writing a program that runs rsync.
The program has two classes: Rsync, MyGUI
The launch itself is done like this
self.command = [
"/usr/bin/rsync",
другие параметры,
]
cmd = list(self.command)
p = subprocess.Popen(cmd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
for line in p.stdout:
p.stdout.flush()
self.runningEdit = QtGui.QTextEdit()
self.runningEdit.append(x)
Answer the question
In order to leave comments, you need to log in
def main():
app = QtGui.QApplication(sys.argv)
ex = MyGUI()
login = "login"
server = "x.x.x.x"
src = "/home/***/rsync/"
dst = "/srv/***/remote"
rs = Rsync(ex, login, server, src, dst)
ex.button_connect(rs)
sys.exit(app.exec_())
if __name__ == '__main__':
main()
It is quite possible that this is wrong , but since print(x) itself is in a function, in the MyGUI class , and the call comes from a loop in the Rsync class , and the output to the console occurs, and in QtGui.QTextEdit() the data is via append(x ) are not updated, it is temporarily decided to force a redraw of the window.
For this, self.repaint() was used . self.update() didn't help.
Popen.communicate() didn't help.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question