def updateServerProgress(self): self.bytesReceived += int(self.tcpServerConnection.bytesAvailable()) self.tcpServerConnection.readAll() self.serverProgressBar.setMaximum(TOTAL_BYTES) self.serverProgressBar.setValue(self.bytesReceived) self.serverStatusLabel.setText( self.tr("Received %dMB" % (self.bytesReceived / (1024 * 1024),)) ) if self.bytesReceived == TOTAL_BYTES: self.tcpServerConnection.close() self.startButton.setEnabled(True) QGuiApplication.restoreOverrideCursor()
def displayError(self, socketError): if socketError == QTcpSocket.RemoteHostClosedError: return QMessageBox.information( self, self.tr("Network error"), self.tr( "The following error occurred: {}.".format(self.tcpClient.errorString()) ), ) self.tcpClient.close() self.tcpServer.close() self.clientProgressBar.reset() self.serverProgressBar.reset() self.clientStatusLabel.setText(self.tr("Client ready")) self.serverStatusLabel.setText(self.tr("Server ready")) self.startButton.setEnabled(True) QGuiApplication.restoreOverrideCursor()