CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Properties | Private Member Functions | Private Attributes | Static Private Attributes
progressbar.ProgressBar Class Reference
Inheritance diagram for progressbar.ProgressBar:

Public Member Functions

def __call__ (self, iterable)
 
def __init__ (self, maxval=None, widgets=None, term_width=None, poll=1, left_justify=True, fd=sys.stderr)
 
def __iter__ (self)
 
def __next__ (self)
 
def finish (self)
 
def percentage (self)
 
def start (self)
 
def update (self, value=None)
 

Public Attributes

 currval
 
 fd
 
 finished
 
 last_update_time
 
 left_justify
 
 maxval
 
 next_update
 
 num_intervals
 
 poll
 
 seconds_elapsed
 
 signal_set
 
 start_time
 
 term_width
 
 update_interval
 
 widgets
 

Static Public Attributes

 next
 

Properties

 percent = property(percentage)
 

Private Member Functions

def _env_size (self)
 
def _format_line (self)
 
def _format_widgets (self)
 
def _handle_resize (self, signum=None, frame=None)
 
def _need_update (self)
 
def _update_widgets (self)
 

Private Attributes

 __iterable
 
 _time_sensitive
 

Static Private Attributes

 __slots__
 
 _DEFAULT_MAXVAL
 
 _DEFAULT_TERMSIZE
 

Detailed Description

The ProgressBar class which updates and prints the bar.

A common way of using it is like:
>>> pbar = ProgressBar().start()
>>> for i in range(100):
...    # do something
...    pbar.update(i+1)
...
>>> pbar.finish()

You can also use a ProgressBar as an iterator:
>>> progress = ProgressBar()
>>> for i in progress(some_iterable):
...    # do something
...

Since the progress bar is incredibly customizable you can specify
different widgets of any type in any order. You can even write your own
widgets! However, since there are already a good number of widgets you
should probably play around with them before moving on to create your own
widgets.

The term_width parameter represents the current terminal width. If the
parameter is set to an integer then the progress bar will use that,
otherwise it will attempt to determine the terminal width falling back to
80 columns if the width cannot be determined.

When implementing a widget's update method you are passed a reference to
the current progress bar. As a result, you have access to the
ProgressBar's methods and attributes. Although there is nothing preventing
you from changing the ProgressBar you should treat it as read only.

Useful methods and attributes include (Public API):
 - currval: current progress (0 <= currval <= maxval)
 - maxval: maximum (and final) value
 - finished: True if the bar has finished (reached 100%)
 - start_time: the time when start() method of ProgressBar was called
 - seconds_elapsed: seconds elapsed since start_time and last call to
                    update
 - percentage(): progress in percent [0..100]

Definition at line 163 of file progressbar.py.

Constructor & Destructor Documentation

◆ __init__()

def progressbar.ProgressBar.__init__ (   self,
  maxval = None,
  widgets = None,
  term_width = None,
  poll = 1,
  left_justify = True,
  fd = sys.stderr 
)
Initializes a progress bar with sane defaults

Definition at line 215 of file progressbar.py.

215  def __init__(self, maxval=None, widgets=None, term_width=None, poll=1,
216  left_justify=True, fd=sys.stderr):
217  '''Initializes a progress bar with sane defaults'''
218 
219  self.maxval = maxval
220  self.widgets = widgets
221  self.fd = fd
222  self.left_justify = left_justify
223 
224  self.signal_set = False
225  if term_width is not None:
226  self.term_width = term_width
227  else:
228  try:
229  self._handle_resize()
230  signal.signal(signal.SIGWINCH, self._handle_resize)
231  self.signal_set = True
232  except (SystemExit, KeyboardInterrupt): raise
233  except:
234  self.term_width = self._env_size()
235 
236  self.__iterable = None
237  self._update_widgets()
238  self.currval = 0
239  self.finished = False
240  self.last_update_time = None
241  self.poll = poll
242  self.seconds_elapsed = 0
243  self.start_time = None
244  self.update_interval = 1
245 
246 

Member Function Documentation

◆ __call__()

def progressbar.ProgressBar.__call__ (   self,
  iterable 
)

Definition at line 247 of file progressbar.py.

247  def __call__(self, iterable):
248  'Use a ProgressBar to iterate through an iterable'
249 
250  try:
251  self.maxval = len(iterable)
252  except:
253  if self.maxval is None:
254  self.maxval = UnknownLength
255 
256  self.__iterable = iter(iterable)
257  return self
258 
259 

References progressbar.ProgressBar.__iterable, and progressbar.ProgressBar.maxval.

◆ __iter__()

def progressbar.ProgressBar.__iter__ (   self)

Definition at line 260 of file progressbar.py.

260  def __iter__(self):
261  return self
262 
263 

◆ __next__()

def progressbar.ProgressBar.__next__ (   self)

Definition at line 264 of file progressbar.py.

264  def __next__(self):
265  try:
266  value = next(self.__iterable)
267  if self.start_time is None: self.start()
268  else: self.update(self.currval + 1)
269  return value
270  except StopIteration:
271  self.finish()
272  raise
273 
274 

References progressbar.ProgressBar.__iterable, progressbar.ProgressBar.currval, PseudoBayesGrouping.finish(), MuonPathAnalyzerPerSL.finish(), MPQualityEnhancerFilter.finish(), MPRedundantFilter.finish(), MuonPathAnalyzerInChamber.finish(), SonicClientBase.finish(), MotherGrouping.finish(), edmTracerLogToSimpleConfig.PathParser.finish(), MPFilter.finish(), HoughGrouping.finish(), MuonPathAssociator.finish(), MuonPathAnalyzer.finish(), RPCIntegrator.finish(), edmTracerLogToSimpleConfig.ConsumesParser.finish(), edm::service::ELdestination.finish(), ztee.GZipLog.finish(), InitialGrouping.finish(), HcalTB02Analysis.finish(), ZdcTestAnalysis.finish(), AlignmentProducerBase.finish(), edm::service::ELadministrator.finish(), CaloTowersCreationAlgo.finish(), dqm-mbProfile.Profile.finish(), edm::pathStatusExpression::ShuntingYardAlgorithm.finish(), esMonitoring.FDOutputListener.finish(), progressbar.ProgressBar.finish(), progressbar.ProgressBar.next, trklet::Timer.start(), service.Service.start(), edm::StreamerOutputModule< Consumer >.start(), RawEventFileWriterForBU.start(), MyWatcher.start(), edm::StreamerFileWriter.start(), edm::service::ConcurrentModuleTimer.start(), edm::StreamerOutputModuleBase.start(), reco::formula::ArrayAdaptor.start(), evf::RecoEventWriterForFU.start(), l1t::Interval< TimeType, PayloadType >.start(), evf::RecoEventOutputModuleForFU< Consumer >.start(), edm::WallclockTimer.start(), cond::persistency::Transaction.start(), edm::CPUTimer.start(), StripCompactDigiSimLinks::TrackRecord.start, Mapper::definition< ScannerT >.start(), evf::EvFBuildingThrottle.start(), cond::persistency::Logger.start(), SiStripMonitorCluster::ClusterProperties.start, validateAlignments.ValidationJob.start, SpecParParser::definition< ScannerT >.start(), cond::RunInfo_t.start, DQMNet.start(), cond::CSScopedSession.start(), evf::FastMonitoringThread.start(), cond::persistency::TransactionScope.start(), validateAlignments.ValidationJobMultiIOV.start, PhysicsTools::VarProcessor::ValueIterator.start, o2olib.O2ORunMgr.start, esMonitoring.FDOutputListener.start, progressbar.ProgressBar.start(), Types.LuminosityBlockRange.start(), Types.EventRange.start(), svgfig.LineAxis.start, looper.Looper.start_time, progressbar.ProgressBar.start_time, frozendict.frozendict.update, DDDWorldObserver< Event >.update(), ECALPFSeedCleaner.update(), KillSecondariesRunAction.update(), KillSecondariesTrackAction.update(), SaveSimTrack.update(), DaqScopeModeHistosUsingDb.update(), FastFedCablingTask.update(), GenericMVAComputerCache.update(), ApvTimingHistosUsingDb.update(), NoiseHistosUsingDb.update(), OptoScanHistosUsingDb.update(), PedestalsHistosUsingDb.update(), reco::KalmanGhostTrackUpdater.update(), PedsFullNoiseHistosUsingDb.update(), PedsOnlyHistosUsingDb.update(), VpspScanHistosUsingDb.update(), ApvTimingTask.update(), VertexTrackUpdator< N >.update(), DummyVertexTrackUpdator< N >.update(), FedTimingTask.update(), VpspScanTask.update(), PrintTrackNumberAction.update(), LagrangeChildUpdator.update(), OptoScanTask.update(), PedestalsTask.update(), Basic2DGenericPFlowClusterizer.update(), FastFedCablingHistosUsingDb.update(), PFMultiDepthClusterizer.update(), FineDelayTask.update(), LatencyTask.update(), AlignableDet.update(), TrajectoryStateUpdator.update(), RecHitTopologicalCleanerBase.update(), MSLayersAtAngle.update(), ErrorCorrelation.update(), GsfMultiStateUpdator.update(), PFlow2DClusterizerWithTime.update(), FedCablingTask.update(), LatencyHistosUsingDb.update(), AlignableDetUnit.update(), PrintSensitive.update(), edm::SubProcessParentageHelper.update(), MonopoleSteppingAction.update(), SCRegressionCalculator< VarCalc >.update(), FineDelayHistosUsingDb.update(), CalibrationScanTask.update(), CalibrationTask.update(), KFStrip1DUpdator.update(), PFClusterEnergyCorrectorBase.update(), KFSwitching1DUpdator.update(), PFCPositionCalculatorBase.update(), CalibrationHistosUsingDb.update(), TkPhase2OTMeasurementDet.update(), RHStopTracer.update(), TkPixelMeasurementDet.update(), NoiseTask.update(), PedsOnlyTask.update(), ChildUpdator.update(), PrintGeomInfoAction.update(), KinematicConstrainedVertexUpdator.update(), PedsFullNoiseTask.update(), CountProcessesAction.update(), PrintGeomSummary.update(), DaqScopeModeTask.update(), AlignableTracker.update(), BaselinePFSCRegression.update(), AlignableCSCChamber.update(), PrintMaterialBudgetInfo.update(), progressbar.Widget.update(), HGCScintSD.update(), PhysicsTools::MVAComputerCache.update(), HGCalSD.update(), HFNoseSD.update(), StoreSecondary.update(), funct::Master< F >.update(), edm::RunningAverage.update(), HGCSD.update(), HGCalTBMB.update(), AlignableComposite.update(), Observer< T >.update(), BinomialProbability.update(), GflashG4Watcher.update(), RealisticSimClusterMapper.update(), KFUpdator.update(), pathelpers::Record.update(), cond::persistency::ITagTable.update(), PFClusterBuilderBase.update(), KalmanVertexTrackUpdator< N >.update(), SimG4FluxProducer.update(), BasicMultiTrajectoryState.update(), cond::persistency::GLOBAL_TAG::Table.update(), ECAL2DPositionCalcWithDepthCorr.update(), CheckSecondary.update(), L1TMuonBarrelKalmanAlgo.update(), KalmanVertexUpdator< N >.update(), AlignableMuon.update(), PhysicsTools::TreeReader.update(), FWJobMetadataManager.update(), TrackingMaterialProducer.update(), SiTrackerMultiRecHitUpdator.update(), HcalTestAnalysis.update(), TrackingVerboseAction.update(), fastsim::Geometry.update(), SiStripConfObject.update(), MuonTrajectoryUpdator.update(), reco::GhostTrackFitter::PredictionUpdater.update(), SiStripPartition.update(), fwlite::RecordWriter.update(), cond::persistency::TAG::Table.update(), TotemTestGem.update(), TimingSD.update(), pos::PixelConfig.update(), CaloTrkProcessing.update(), FWParameterSetterBase.update(), edm::service::CondorStatusService.update(), KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >.update(), FiberSD.update(), Alignable.update(), DAClusterizerInZ.update(), HGCPassive.update(), TotemRPSD.update(), MuonServiceProxy.update(), progressbar.Timer.update(), HCalSD.update(), MuonSensitiveDetector.update(), PPSDiamondSD.update(), TkAccumulatingSensitiveDetector.update(), simwatcher::BeginOfTrackCounter.update(), HcaluLUTTPGCoder.update(), MuonUpdatorAtVertex.update(), LaserAlignmentSimulation.update(), DictTypes.SortedAndFixedKeysDict.update, ApvAnalysisFactory.update(), HcalForwardAnalysis.update(), TotemSD.update(), DTVDriftCalibration::cellInfo.update(), sim_act::Signaler< T >.update(), SimTracer.update(), PPSPixelSD.update(), progressbar.WidgetHFill.update(), FP420SD.update(), CaloSteppingAction.update(), DTSegmentUpdator.update(), HcalTB02Analysis.update(), DoCastorAnalysis.update(), ZdcTestAnalysis.update(), PhysicsTools::TreeReader::Value.update(), DictTypes.FixedKeysDict.update, CastorTestAnalysis.update(), EcalTBH4Trigger.update(), SingleParticleEvent.update(), BetafuncEvtVtxGenerator.update(), edm::ProductProvenanceRetriever.update(), CaloSD.update(), InitialClusteringStepBase.update(), sistrip::RawToDigiUnpacker.update(), PhysicsTools::MVAModuleHelper< Record, Object, Filler >::Value.update(), HcalTB04Analysis.update(), jsoncollector::IntJ.update(), HLTScalersClient::CountLSFifo_t.update(), progressbar.Bar.update(), TrajectoryStateOnSurface.update(), evf::FastMonitoringService::Encoding.update(), PFECALSuperClusterAlgo.update(), GaussianSumUtilities1D.update(), DynamicTruncation.update(), edm::service::SimpleMemoryCheck.update(), edm::BMixingModule.update(), progressbar.BouncingBar.update(), CastorShowerLibraryMaker.update(), DTRecSegment2D.update(), jsoncollector::DoubleJ.update(), DQMNet::Peer.update, cond::persistency::IPayloadMigrationTable.update(), FWPSetTableManager.update(), StandAloneMuonFilter.update(), DQMNet::AutoPeer.update, G4StepStatistics.update(), progressbar.FormatLabel.update(), FWLiteESRecordWriterAnalyzer.update(), CommissioningTask.update(), StMeasurementDetSet.update(), jsoncollector::StringJ.update(), FP420Test.update(), BscTest.update(), cond::persistency::IGTTable.update(), dqm-mbProfile.Profile.update(), Folder.update(), DAClusterizerInZ_vect.update(), dqm::impl::MonitorElement.update(), jsoncollector::HistoJ< T >.update(), DAClusterizerInZT_vect.update(), BasicTrajectoryState.update(), PxMeasurementDetSet.update(), progressbar.ProgressBar.update(), Phase2OTMeasurementDetSet.update(), edmStreamStallGrapher.Stack.update(), crabFunctions.CrabTask.update(), edmNew::DetSetVector< T >.update(), and Config.FilteredStream.update.

◆ _env_size()

def progressbar.ProgressBar._env_size (   self)
private

Definition at line 280 of file progressbar.py.

280  def _env_size(self):
281  'Tries to find the term_width from the environment.'
282 
283  return int(os.environ.get('COLUMNS', self._DEFAULT_TERMSIZE)) - 1
284 
285 

References progressbar.ProgressBar._DEFAULT_TERMSIZE, and createfilelist.int.

◆ _format_line()

def progressbar.ProgressBar._format_line (   self)
private

Definition at line 327 of file progressbar.py.

327  def _format_line(self):
328  'Joins the widgets and justifies the line'
329 
330  widgets = ''.join(self._format_widgets())
331 
332  if self.left_justify: return widgets.ljust(self.term_width)
333  else: return widgets.rjust(self.term_width)
334 
335 

References progressbar.ProgressBar._format_widgets(), join(), progressbar.ProgressBar.left_justify, and progressbar.ProgressBar.term_width.

◆ _format_widgets()

def progressbar.ProgressBar._format_widgets (   self)
private

Definition at line 300 of file progressbar.py.

300  def _format_widgets(self):
301  result = []
302  expanding = []
303  width = self.term_width
304 
305  for index, widget in enumerate(self.widgets):
306  if isinstance(widget, WidgetHFill):
307  result.append(widget)
308  expanding.insert(0, index)
309  else:
310  widget = format_updatable(widget, self)
311  result.append(widget)
312  width -= len(widget)
313 
314  count = len(expanding)
315  while count:
316  portion = max(int(math.ceil(width * 1. / count)), 0)
317  index = expanding.pop()
318  count -= 1
319 
320  widget = result[index].update(self, portion)
321  width -= len(widget)
322  result[index] = widget
323 
324  return result
325 
326 

References progressbar.format_updatable(), createfilelist.int, SiStripPI.max, progressbar.ProgressBar.term_width, progressbar.ProgressBar.update(), and progressbar.ProgressBar.widgets.

Referenced by progressbar.ProgressBar._format_line().

◆ _handle_resize()

def progressbar.ProgressBar._handle_resize (   self,
  signum = None,
  frame = None 
)
private

Definition at line 286 of file progressbar.py.

286  def _handle_resize(self, signum=None, frame=None):
287  'Tries to catch resize signals sent from the terminal.'
288 
289  h, w = array('h', ioctl(self.fd, termios.TIOCGWINSZ, '\0' * 8))[:2]
290  self.term_width = w
291 
292 

References mps_check.array, hippyaddtobaddatafiles.KeepWhileOpenFile.fd, progressbar.ProgressBar.fd, and progressbar.ProgressBar.term_width.

◆ _need_update()

def progressbar.ProgressBar._need_update (   self)
private

Definition at line 336 of file progressbar.py.

336  def _need_update(self):
337  'Returns whether the ProgressBar should redraw the line.'
338  if self.currval >= self.next_update or self.finished: return True
339 
340  delta = time.time() - self.last_update_time
341  return self._time_sensitive and delta > self.poll
342 
343 

References progressbar.ProgressBar._time_sensitive, progressbar.ProgressBar.currval, progressbar.ProgressBar.finished, progressbar.ProgressBar.last_update_time, progressbar.ProgressBar.next_update, and progressbar.ProgressBar.poll.

Referenced by progressbar.ProgressBar.update().

◆ _update_widgets()

def progressbar.ProgressBar._update_widgets (   self)
private

Definition at line 344 of file progressbar.py.

344  def _update_widgets(self):
345  'Checks all widgets for the time sensitive bit'
346 
347  self._time_sensitive = any(getattr(w, 'TIME_SENSITIVE', False)
348  for w in self.widgets)
349 
350 

◆ finish()

def progressbar.ProgressBar.finish (   self)

Definition at line 403 of file progressbar.py.

403  def finish(self):
404  'Puts the ProgressBar bar in the finished state.'
405 
406  self.finished = True
407  self.update(self.maxval)
408  self.fd.write('\n')
409  if self.signal_set:
410  signal.signal(signal.SIGWINCH, signal.SIG_DFL)

References hippyaddtobaddatafiles.KeepWhileOpenFile.fd, progressbar.ProgressBar.fd, progressbar.ProgressBar.finished, progressbar.ProgressBar.maxval, progressbar.ProgressBar.signal_set, frozendict.frozendict.update, DDDWorldObserver< Event >.update(), KillSecondariesRunAction.update(), KillSecondariesTrackAction.update(), ECALPFSeedCleaner.update(), SaveSimTrack.update(), DaqScopeModeHistosUsingDb.update(), FastFedCablingTask.update(), ApvTimingHistosUsingDb.update(), VertexTrackUpdator< N >.update(), DummyVertexTrackUpdator< N >.update(), NoiseHistosUsingDb.update(), PedestalsHistosUsingDb.update(), OptoScanHistosUsingDb.update(), PedsFullNoiseHistosUsingDb.update(), PedsOnlyHistosUsingDb.update(), VpspScanHistosUsingDb.update(), ApvTimingTask.update(), PrintTrackNumberAction.update(), GenericMVAComputerCache.update(), FedTimingTask.update(), VpspScanTask.update(), reco::KalmanGhostTrackUpdater.update(), PedestalsTask.update(), OptoScanTask.update(), LagrangeChildUpdator.update(), AlignableDet.update(), FastFedCablingHistosUsingDb.update(), TrajectoryStateUpdator.update(), FineDelayTask.update(), Basic2DGenericPFlowClusterizer.update(), LatencyTask.update(), PFMultiDepthClusterizer.update(), ErrorCorrelation.update(), GsfMultiStateUpdator.update(), RecHitTopologicalCleanerBase.update(), MSLayersAtAngle.update(), FedCablingTask.update(), PFlow2DClusterizerWithTime.update(), LatencyHistosUsingDb.update(), PrintSensitive.update(), AlignableDetUnit.update(), edm::SubProcessParentageHelper.update(), MonopoleSteppingAction.update(), FineDelayHistosUsingDb.update(), KFStrip1DUpdator.update(), CalibrationScanTask.update(), CalibrationTask.update(), SCRegressionCalculator< VarCalc >.update(), KFSwitching1DUpdator.update(), PFClusterEnergyCorrectorBase.update(), CalibrationHistosUsingDb.update(), RHStopTracer.update(), PFCPositionCalculatorBase.update(), TkPhase2OTMeasurementDet.update(), NoiseTask.update(), TkPixelMeasurementDet.update(), PedsOnlyTask.update(), PrintGeomInfoAction.update(), ChildUpdator.update(), CountProcessesAction.update(), PrintGeomSummary.update(), PedsFullNoiseTask.update(), KinematicConstrainedVertexUpdator.update(), AlignableTracker.update(), DaqScopeModeTask.update(), PrintMaterialBudgetInfo.update(), BaselinePFSCRegression.update(), progressbar.Widget.update(), AlignableCSCChamber.update(), HGCScintSD.update(), PhysicsTools::MVAComputerCache.update(), HFNoseSD.update(), HGCalSD.update(), StoreSecondary.update(), funct::Master< F >.update(), edm::RunningAverage.update(), HGCSD.update(), HGCalTBMB.update(), Observer< T >.update(), BinomialProbability.update(), AlignableComposite.update(), GflashG4Watcher.update(), KFUpdator.update(), RealisticSimClusterMapper.update(), pathelpers::Record.update(), cond::persistency::ITagTable.update(), PFClusterBuilderBase.update(), KalmanVertexTrackUpdator< N >.update(), SimG4FluxProducer.update(), cond::persistency::GLOBAL_TAG::Table.update(), BasicMultiTrajectoryState.update(), L1TMuonBarrelKalmanAlgo.update(), CheckSecondary.update(), ECAL2DPositionCalcWithDepthCorr.update(), KalmanVertexUpdator< N >.update(), AlignableMuon.update(), FWJobMetadataManager.update(), PhysicsTools::TreeReader.update(), TrackingMaterialProducer.update(), HcalTestAnalysis.update(), TrackingVerboseAction.update(), SiTrackerMultiRecHitUpdator.update(), fastsim::Geometry.update(), fwlite::RecordWriter.update(), reco::GhostTrackFitter::PredictionUpdater.update(), SiStripPartition.update(), MuonTrajectoryUpdator.update(), SiStripConfObject.update(), TimingSD.update(), TotemTestGem.update(), pos::PixelConfig.update(), cond::persistency::TAG::Table.update(), CaloTrkProcessing.update(), FWParameterSetterBase.update(), edm::service::CondorStatusService.update(), FiberSD.update(), KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >.update(), DAClusterizerInZ.update(), Alignable.update(), HGCPassive.update(), TotemRPSD.update(), progressbar.Timer.update(), HCalSD.update(), MuonServiceProxy.update(), MuonSensitiveDetector.update(), PPSDiamondSD.update(), simwatcher::BeginOfTrackCounter.update(), TkAccumulatingSensitiveDetector.update(), HcaluLUTTPGCoder.update(), MuonUpdatorAtVertex.update(), LaserAlignmentSimulation.update(), DictTypes.SortedAndFixedKeysDict.update, ApvAnalysisFactory.update(), HcalForwardAnalysis.update(), TotemSD.update(), DTVDriftCalibration::cellInfo.update(), sim_act::Signaler< T >.update(), SimTracer.update(), PPSPixelSD.update(), progressbar.WidgetHFill.update(), CaloSteppingAction.update(), FP420SD.update(), DTSegmentUpdator.update(), HcalTB02Analysis.update(), DoCastorAnalysis.update(), ZdcTestAnalysis.update(), DictTypes.FixedKeysDict.update, PhysicsTools::TreeReader::Value.update(), CastorTestAnalysis.update(), EcalTBH4Trigger.update(), SingleParticleEvent.update(), BetafuncEvtVtxGenerator.update(), edm::ProductProvenanceRetriever.update(), CaloSD.update(), InitialClusteringStepBase.update(), sistrip::RawToDigiUnpacker.update(), PhysicsTools::MVAModuleHelper< Record, Object, Filler >::Value.update(), HcalTB04Analysis.update(), jsoncollector::IntJ.update(), HLTScalersClient::CountLSFifo_t.update(), progressbar.Bar.update(), TrajectoryStateOnSurface.update(), evf::FastMonitoringService::Encoding.update(), PFECALSuperClusterAlgo.update(), GaussianSumUtilities1D.update(), DynamicTruncation.update(), edm::service::SimpleMemoryCheck.update(), edm::BMixingModule.update(), progressbar.BouncingBar.update(), CastorShowerLibraryMaker.update(), DTRecSegment2D.update(), jsoncollector::DoubleJ.update(), DQMNet::Peer.update, cond::persistency::IPayloadMigrationTable.update(), FWPSetTableManager.update(), StandAloneMuonFilter.update(), DQMNet::AutoPeer.update, G4StepStatistics.update(), progressbar.FormatLabel.update(), FWLiteESRecordWriterAnalyzer.update(), CommissioningTask.update(), StMeasurementDetSet.update(), jsoncollector::StringJ.update(), FP420Test.update(), BscTest.update(), cond::persistency::IGTTable.update(), dqm-mbProfile.Profile.update(), Folder.update(), DAClusterizerInZ_vect.update(), dqm::impl::MonitorElement.update(), jsoncollector::HistoJ< T >.update(), DAClusterizerInZT_vect.update(), BasicTrajectoryState.update(), PxMeasurementDetSet.update(), progressbar.ProgressBar.update(), Phase2OTMeasurementDetSet.update(), edmStreamStallGrapher.Stack.update(), crabFunctions.CrabTask.update(), edmNew::DetSetVector< T >.update(), Config.FilteredStream.update, and writeEcalDQMStatus.write.

Referenced by progressbar.ProgressBar.__next__().

◆ percentage()

def progressbar.ProgressBar.percentage (   self)

Definition at line 293 of file progressbar.py.

293  def percentage(self):
294  'Returns the progress as a percentage.'
295  return self.currval * 100.0 / self.maxval
296 

References progressbar.ProgressBar.currval, and progressbar.ProgressBar.maxval.

◆ start()

def progressbar.ProgressBar.start (   self)
Starts measuring time, and prints the bar at 0%.

It returns self so you can use it like this:
>>> pbar = ProgressBar().start()
>>> for i in range(100):
...    # do something
...    pbar.update(i+1)
...
>>> pbar.finish()

Definition at line 374 of file progressbar.py.

374  def start(self):
375  '''Starts measuring time, and prints the bar at 0%.
376 
377  It returns self so you can use it like this:
378  >>> pbar = ProgressBar().start()
379  >>> for i in range(100):
380  ... # do something
381  ... pbar.update(i+1)
382  ...
383  >>> pbar.finish()
384  '''
385 
386  if self.maxval is None:
387  self.maxval = self._DEFAULT_MAXVAL
388 
389  self.num_intervals = max(100, self.term_width)
390  self.next_update = 0
391 
392  if self.maxval is not UnknownLength:
393  if self.maxval < 0: raise ValueError('Value out of range')
394  self.update_interval = self.maxval / self.num_intervals
395 
396 
397  self.start_time = self.last_update_time = time.time()
398  self.update(0)
399 
400  return self
401 
402 

References progressbar.ProgressBar._DEFAULT_MAXVAL, and progressbar.ProgressBar.maxval.

Referenced by progressbar.ProgressBar.__next__().

◆ update()

def progressbar.ProgressBar.update (   self,
  value = None 
)

Definition at line 351 of file progressbar.py.

351  def update(self, value=None):
352  'Updates the ProgressBar to a new value.'
353 
354  if value is not None and value is not UnknownLength:
355  if (self.maxval is not UnknownLength
356  and not 0 <= value <= self.maxval):
357 
358  raise ValueError('Value out of range')
359 
360  self.currval = value
361 
362 
363  if not self._need_update(): return
364  if self.start_time is None:
365  raise RuntimeError('You must call "start" before calling "update"')
366 
367  now = time.time()
368  self.seconds_elapsed = now - self.start_time
369  self.next_update = self.currval + self.update_interval
370  self.fd.write(self._format_line() + '\r')
371  self.last_update_time = now
372 
373 

References progressbar.ProgressBar._need_update(), progressbar.ProgressBar.currval, progressbar.ProgressBar.maxval, progressbar.ProgressBar.seconds_elapsed, looper.Looper.start_time, and progressbar.ProgressBar.start_time.

Referenced by progressbar.ProgressBar.__next__(), MatrixUtil.Matrix.__setitem__(), MatrixUtil.Steps.__setitem__(), progressbar.ProgressBar._format_widgets(), progressbar.ProgressBar.finish(), and MatrixUtil.Steps.overwrite().

Member Data Documentation

◆ __iterable

progressbar.ProgressBar.__iterable
private

◆ __slots__

progressbar.ProgressBar.__slots__
staticprivate

Definition at line 206 of file progressbar.py.

◆ _DEFAULT_MAXVAL

progressbar.ProgressBar._DEFAULT_MAXVAL
staticprivate

Definition at line 212 of file progressbar.py.

Referenced by progressbar.ProgressBar.start().

◆ _DEFAULT_TERMSIZE

progressbar.ProgressBar._DEFAULT_TERMSIZE
staticprivate

Definition at line 213 of file progressbar.py.

Referenced by progressbar.ProgressBar._env_size().

◆ _time_sensitive

progressbar.ProgressBar._time_sensitive
private

Definition at line 347 of file progressbar.py.

Referenced by progressbar.ProgressBar._need_update().

◆ currval

progressbar.ProgressBar.currval

◆ fd

progressbar.ProgressBar.fd

◆ finished

progressbar.ProgressBar.finished

◆ last_update_time

progressbar.ProgressBar.last_update_time

Definition at line 239 of file progressbar.py.

Referenced by progressbar.ProgressBar._need_update().

◆ left_justify

progressbar.ProgressBar.left_justify

Definition at line 221 of file progressbar.py.

Referenced by progressbar.ProgressBar._format_line().

◆ maxval

progressbar.ProgressBar.maxval

◆ next

progressbar.ProgressBar.next
static

Definition at line 277 of file progressbar.py.

Referenced by progressbar.ProgressBar.__next__().

◆ next_update

progressbar.ProgressBar.next_update

Definition at line 369 of file progressbar.py.

Referenced by progressbar.ProgressBar._need_update().

◆ num_intervals

progressbar.ProgressBar.num_intervals

Definition at line 389 of file progressbar.py.

◆ poll

progressbar.ProgressBar.poll

Definition at line 240 of file progressbar.py.

Referenced by progressbar.ProgressBar._need_update().

◆ seconds_elapsed

progressbar.ProgressBar.seconds_elapsed

Definition at line 241 of file progressbar.py.

Referenced by progressbar.ProgressBar.update().

◆ signal_set

progressbar.ProgressBar.signal_set

Definition at line 223 of file progressbar.py.

Referenced by progressbar.ProgressBar.finish().

◆ start_time

progressbar.ProgressBar.start_time

◆ term_width

progressbar.ProgressBar.term_width

◆ update_interval

progressbar.ProgressBar.update_interval

Definition at line 243 of file progressbar.py.

◆ widgets

progressbar.ProgressBar.widgets

Definition at line 219 of file progressbar.py.

Referenced by progressbar.ProgressBar._format_widgets().

Property Documentation

◆ percent

progressbar.ProgressBar.percent = property(percentage)
static

Definition at line 297 of file progressbar.py.

join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
mps_check.array
array
Definition: mps_check.py:216
any
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:34
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
createfilelist.int
int
Definition: createfilelist.py:10
writeEcalDQMStatus.write
write
Definition: writeEcalDQMStatus.py:48
command_line.start
start
Definition: command_line.py:167
progressbar.format_updatable
def format_updatable(updatable, pbar)
Definition: progressbar.py:411
update
#define update(a, b)
Definition: TrackClassifier.cc:10
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31