def _updatePieceEstimates(self, totalFileSize): if not self.pieceSize.GetValue() == u'': pieceSize = self.pieceSizeMapper[self.pieceSize.GetValue()] pieceCount = int(math.ceil(totalFileSize / (pieceSize * 1.0))) self.torrentDataSize.SetLabel(dataAmountToString(totalFileSize)) self.amountOfPieces.SetLabel(str(pieceCount)) self.torrentFileSize.SetLabel('>'+dataAmountToString(pieceCount*20)) self.Update() self.progressBoxSizer.Layout()
def OnTimer(self, event): stats = self.torrentCreator.getStats() processed, total = scaleInt(10000, stats['processedFileSize'], stats['totalFileSize']) self.totalProgressBar.SetRange(total) self.totalProgressBar.SetValue(processed) self.totalProgressText.SetLabel('%s/%s' % (dataAmountToString(stats['processedFileSize']).strip(), dataAmountToString(stats['totalFileSize']))) self.currentProgressBar.SetValue(round(stats['currentFileProgress']*10000, 0)) self.currentProgressText.SetLabel('%.2f' % (round(stats['currentFileProgress']*100, 2))+'%') self.currentFileName.SetLabel(stats['currentFileName']) self.currentFileProgress.SetLabel('%i/%i Files' % (stats['currentFileNumber'], stats['amountOfFiles'])) self.Update() self.progressBoxSizer.Layout() self._updatePieceEstimates(stats['totalFileSize']) if not self.torrentCreator.isRunning(): #finished self.createButton.SetLabel(u'Create') self.pieceBoxUpdateButton.Enable() self.Update() self.progressBoxSizer.Layout() self.updateTimer.Stop() lastError = self.torrentCreator.getLastError() if lastError is None: #creation succeeded showInfoMessage(self, u'The torrent was successfuly created.') else: #creation failed showErrorMessage(self, u'The creation of the torrent failed:\n%s', lastError.reason) self.torrentCreator.reset()