0

I am trying to redirect the terminal log to a QTextEdit or QLabel. The terminal log shows data read from Telnet, using the module telnetlib and the command telnet.interact(). The problem is that, after the execution of the command, nothing happend. I have to use the interact command because the data change continously, infact with the telnet Iread a file log. Also using a separate Thread for the telnet i can't do that. Using read_eager or read_lazy or read_all, i can't get any data from the server.

This is the code:

    def _createTelnetThread(self):
        self.thread = QThread()
        self.worker = Worker()
        self.worker.moveToThread(self.thread)
        self.thread.started.connect(self.worker.run)
        self.thread.finished.connect(self.thread.quit)
        self.thread.finished.connect(self.worker.deleteLater)
        self.thread.finished.connect(self.thread.deleteLater)
        self.worker.progress.connect(self.dataReady)
        self.thread.start()

...

class Worker(QObject):
    finished = pyqtSignal()
    progress = pyqtSignal()

    def run(self):
        self.tn = telnetlib.Telnet('10.114.1.17',555)
        self.progress.emit(self.tn.interact())

...

def dataReady(self, data):
        self._logLabel.setText(data)

Did you have any advice?

breso
  • 1

0 Answers0