def updateStatus(self, status, finished=False): elapsed = self.runTime.Time() / 1000 self.m_textElapsedTime.SetLabel(utils.timeStampFmt(elapsed)) if status: self.m_textSync.SetLabel( _('Synchronization: {} points').format(status.points)) self.m_textCorrelation.SetLabel('{:.2f} %'.format(100 * status.factor)) self.m_textFormula.SetLabel(str(status.formula)) self.m_textMaxChange.SetLabel( utils.timeStampFractionFmt(status.maxChange)) if finished: self.m_gaugeProgress.SetValue(100) else: self.m_gaugeProgress.SetValue(100 * status.progress) if status.subReady and not self.m_bitmapTick.IsShown(): self.m_bitmapCross.Hide() self.m_bitmapTick.Show() self.m_buttonSave.Enable() if status.running: self.m_textInitialSyncInfo.Show() self.Fit() self.Layout() self.updateStatusErrors()
def onUpdateTimerTick(self, event): if self.isRunning: stats = self.sync.getStats() elapsed = time.time() - self.startTime maxChange = self.sync.getMaxChange() self.m_textSync.SetLabel(_('Synchronization: {} points').format(stats.points)) self.m_textElapsedTime.SetLabel(utils.timeStampFmt(elapsed)) self.m_textCorrelation.SetLabel('{:.2f} %'.format(100.0 * stats.factor)) self.m_textFormula.SetLabel(str(stats.formula)) self.m_textMaxChange.SetLabel(utils.timeStampFractionFmt(maxChange)) if not self.isCorrelated and stats.correlated: self.isCorrelated = stats.correlated self.m_bitmapCross.Hide() self.m_bitmapTick.Show() if self.isSubReady: self.onSubReady() self.Layout() if self.listener: self.listener.onSynchronized(self, stats) if self.sync.isRunning(): self.setProgress(self.sync.getProgress()) else: self.stop(finished=True) self.setProgress(1.0) if self.listener: self.listener.onSynchronizationDone(self, stats)
def printStats(self, status, endline=False): if pr.verbosity >= 1: progress = 100 * min( max(status.progress, status.effort / settings().minEffort, 0), 1) msg = '[+] synchronization {:3.0f}%: {} points'.format( progress, status.points) if pr.verbosity >= 2: msg += ', correlation={:.2f}, formula={}, maxChange={}'.format( 100 * status.factor, str(status.formula), utils.timeStampFractionFmt(status.maxChange)) if pr.verbosity >= 3: pr.println(1, msg) else: pr.reprint(1, msg, endline)
def updateSelectedTask(self): status = self.selectedTask and self.selectedTask.status if status: self.m_textPoints.SetLabel(str(status.points)) self.m_textCorrelation.SetLabel('{:.2f} %'.format(100.0 * status.factor)) self.m_textFormula.SetLabel(str(status.formula)) self.m_textMaxChange.SetLabel( utils.timeStampFractionFmt(status.maxChange)) else: self.m_textPoints.SetLabel('-') self.m_textCorrelation.SetLabel('-') self.m_textFormula.SetLabel('-') self.m_textMaxChange.SetLabel('-') if self.selectedTask: msgs = { 'run': _('synchronizing...'), 'idle': _('waiting...'), 'success': _('synchronized'), 'fail': _('couldn\'t synchronize') } state = self.selectedTask.state self.m_textStatus.SetLabel(msgs[state]) tick = state == 'success' if self.m_bitmapTick.IsShown() != tick: self.m_bitmapTick.Show(tick) cross = state == 'fail' if self.m_bitmapCross.IsShown() != cross: self.m_bitmapCross.Show(cross) else: self.m_textStatus.SetLabel('-') showErrors = bool(self.selectedTask and self.selectedTask.errors) if showErrors != self.m_textErrorTitle.IsShown(): self.m_textErrorTitle.Show(showErrors) self.m_textErrorDetails.Show(showErrors) self.Layout()
def printStats(self, status, finished=False): if pr.verbosity >= 1: if finished: progress = 1.0 else: progress = status.progress effort = settings().minEffort if effort: progress = min(max(progress, status.effort / effort, 0), 1) msg = '[+] {}: progress {:3.0f}%, {} points'.format( utils.timeStampFmt(time.monotonic() - self.startTime), 100 * progress, status.points) if pr.verbosity >= 2: msg += ', correlation={:.2f}, formula={}, maxChange={}'.format( 100 * status.factor, str(status.formula), utils.timeStampFractionFmt(status.maxChange)) if pr.verbosity >= 3: pr.println(1, msg) else: pr.reprint(1, msg)
def onJobUpdate(self, task, status, finished=False): elapsed = time.monotonic() - self.startTime self.m_textElapsedTime.SetLabel(utils.timeStampFmt(elapsed)) self.m_textSync.SetLabel(_('Synchronization: {} points').format(status.points)) self.m_textCorrelation.SetLabel('{:.2f} %'.format(100 * status.factor)) self.m_textFormula.SetLabel(str(status.formula)) self.m_textMaxChange.SetLabel(utils.timeStampFractionFmt(status.maxChange)) if finished: self.m_gaugeProgress.SetValue(100) else: self.m_gaugeProgress.SetValue(100 * status.progress) if status.correlated and not self.m_bitmapTick.IsShown(): self.m_bitmapCross.Hide() self.m_bitmapTick.Show() self.m_buttonSave.Enable() if self.sync.isRunning(): self.m_textInitialSyncInfo.Show() self.Fit() self.Layout() self.updateStatusErrors()
def pushWord(self, word): print('{:>8}: {} - {}: {}'.format( self.prefix, timeStampFractionFmt(word.time), timeStampFractionFmt(word.time + word.duration), word.text))