# HG changeset patch # User Dirk Olmes # Date 1411262597 -7200 # Node ID 191f6296a2a47e6e9365c339ac991e241e183fc6 # Parent dfefc456dc93eb682242dda1b59bef434d59850d display the output of the respective viewer command in a separate log view diff -r dfefc456dc93 -r 191f6296a2a4 RemoteViewer/Connection.py --- a/RemoteViewer/Connection.py Sun Sep 21 02:45:24 2014 +0200 +++ b/RemoteViewer/Connection.py Sun Sep 21 03:23:17 2014 +0200 @@ -24,19 +24,19 @@ return 'connection "{}" of type {} to {} with user {} and geometry {}'.format(self.title, self.type, self.host, self.user, self.geometry) def setType(self, type): - '''This method is connected to a slot in the GUI''' + '''This is a slot that is connected to a signal in the GUI''' self.type = type def setHost(self, hostname): - '''This method is connected to a slot in the GUI''' + '''This is a slot that is connected to a signal in the GUI''' self.host = hostname def setUser(self, user): - '''This method is connected to a slot in the GUI''' + '''This is a slot that is connected to a signal in the GUI''' self.user= user def setGeometry(self, geometry): - '''This method is connected to a slot in the GUI''' + '''This is a slot that is connected to a signal in the GUI''' self.geometry = geometry def displayString(self): @@ -55,10 +55,10 @@ json[key] = getattr(self, key) return json - def open(self): + def open(self, parent): if self.type == 'vnc': - VncViewer(self).open() + VncViewer(self).open(parent) elif self.type == 'rdp': - FreeRdp(self).open() + FreeRdp(self).open(parent) else: raise ValueError('unknown type: ' + self.type) diff -r dfefc456dc93 -r 191f6296a2a4 RemoteViewer/LogViewer.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RemoteViewer/LogViewer.py Sun Sep 21 03:23:17 2014 +0200 @@ -0,0 +1,15 @@ +from PyQt4.QtCore import pyqtSignal +from PyQt4.QtGui import QDialog +from .Ui_LogViewer import Ui_LogViewer + +class LogViewer(QDialog): + appendSignal = pyqtSignal(['QString']) + + def __init__(self): + super(LogViewer, self).__init__() + self.ui = Ui_LogViewer() + self.ui.setupUi(self) + self.appendSignal.connect(self.ui.logText.appendPlainText) + + def append(self, line): + self.appendSignal.emit(line) diff -r dfefc456dc93 -r 191f6296a2a4 RemoteViewer/LogViewer.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RemoteViewer/LogViewer.ui Sun Sep 21 03:23:17 2014 +0200 @@ -0,0 +1,31 @@ + + + LogViewer + + + + 0 + 0 + 613 + 463 + + + + Dialog + + + + + + + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + diff -r dfefc456dc93 -r 191f6296a2a4 RemoteViewer/RemoteViewer.py --- a/RemoteViewer/RemoteViewer.py Sun Sep 21 02:45:24 2014 +0200 +++ b/RemoteViewer/RemoteViewer.py Sun Sep 21 03:23:17 2014 +0200 @@ -33,7 +33,7 @@ @ExceptionSafeSlot('QModelIndex') def openConnection(self, index): connection = index.internalPointer() - connection.open() + connection.open(self) def close(self): self.settings.persist() diff -r dfefc456dc93 -r 191f6296a2a4 RemoteViewer/Viewer.py --- a/RemoteViewer/Viewer.py Sun Sep 21 02:45:24 2014 +0200 +++ b/RemoteViewer/Viewer.py Sun Sep 21 03:23:17 2014 +0200 @@ -1,32 +1,43 @@ import subprocess + from threading import Thread +from .LogViewer import LogViewer class ReadThread(Thread): - def __init__(self, output): + def __init__(self, output, viewer): super(ReadThread, self).__init__() self.daemon = True self.output = output + self.viewer = viewer def run(self): for line in iter(self.output.readline, b''): line = line.decode('utf-8') line = line.rstrip('\n') print(line) + self.viewer.append(line) class AbstractViewer(object): def __init__(self, connection): self.connection = connection self.process = None - def open(self): + def open(self, parent): command = self.buildCommand() self.process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.__startLogThread(self.process.stdout) self.process.wait() def __startLogThread(self, output): - readThread = ReadThread(output) + logViewer = self.__createLogViewer() + readThread = ReadThread(output, logViewer) readThread.start() + logViewer.exec_() + + def __createLogViewer(self): + viewer = LogViewer() + viewer.setWindowTitle(self.connection.displayString()) + return viewer class VncViewer(AbstractViewer): def buildCommand(self):