def onSwitchPerspective(self, perspective): self.stop_logging() if perspective == "Remote": if hasattr(self, 'hostName') and hasattr(self, 'port'): host, port = self.hostName, self.port else: isValid = False dft = "%s:%d" % (socket.gethostname(), logging.handlers.DEFAULT_TCP_LOGGING_PORT) while not isValid: txt, res = Qt.QInputDialog.getText( self, "Please input remote logging host and port", "Location (<host>:<port>):", Qt.QLineEdit.Normal, dft) if not res: return try: host, port = str(txt).split(":", 1) port = int(port) isValid = True except: Qt.QMessageBox.information( self, "Invalid name", "Please type a valid <host>:<port>") ret = QBaseTableWidget.onSwitchPerspective(self, perspective) qmodel = self.getQModel() qmodel.connect_logging(host=host, port=port) else: ret = QBaseTableWidget.onSwitchPerspective(self, perspective) return ret
def onSwitchPerspective(self, perspective): self.stop_logging() if perspective == "Remote": if hasattr(self, 'hostName') and hasattr(self, 'port'): host, port = self.hostName, self.port else: isValid = False dft = "%s:%d" % (socket.gethostname(), logging.handlers.DEFAULT_TCP_LOGGING_PORT) while not isValid: txt, res = Qt.QInputDialog.getText(self, "Please input remote logging host and port", "Location (<host>:<port>):", Qt.QLineEdit.Normal, dft) if not res: return try: host, port = str(txt).split(":", 1) port = int(port) isValid = True except: Qt.QMessageBox.information(self, "Invalid name", "Please type a valid <host>:<port>") ret = QBaseTableWidget.onSwitchPerspective(self, perspective) qmodel = self.getQModel() qmodel.connect_logging(host=host, port=port) else: ret = QBaseTableWidget.onSwitchPerspective(self, perspective) return ret