CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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__
 
def __init__
 
def __iter__
 
def __next__
 
def finish
 
def percentage
 
def start
 
def update
 

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 = __next__
 

Properties

 percent = property(percentage)
 

Private Member Functions

def _env_size
 
def _format_line
 
def _format_widgets
 
def _handle_resize
 
def _need_update
 
def _update_widgets
 

Private Attributes

 __iterable
 
 _time_sensitive
 

Static Private Attributes

tuple __slots__
 
int _DEFAULT_MAXVAL = 100
 
int _DEFAULT_TERMSIZE = 80
 

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

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 216 of file progressbar.py.

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

Member Function Documentation

def progressbar.ProgressBar.__call__ (   self,
  iterable 
)

Definition at line 247 of file progressbar.py.

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

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

Definition at line 260 of file progressbar.py.

261  def __iter__(self):
262  return self
263 
def progressbar.ProgressBar.__next__ (   self)

Definition at line 264 of file progressbar.py.

References progressbar.ProgressBar.__iterable, progressbar.ProgressBar.currval, CrabWatch.CrabWatch.finish, HcalTB02Analysis.finish(), edm::RegionIndex< T >.finish(), ztee.GZipLog.finish(), edm::service::ELdestination.finish(), ZdcTestAnalysis.finish(), edm::service::ELadministrator.finish(), CaloTowersCreationAlgo.finish(), esMonitoring.FDOutputListener.finish(), progressbar.ProgressBar.finish(), progressbar.ProgressBar.next, service.Service.start(), FastTimer.start(), ora::Transaction.start(), cond::DbScopedTransaction.start(), ora::ScopedTransaction.start(), edm::StreamerOutputModule< Consumer >.start(), cond::DbTransaction.start(), edm::StreamerOutputModuleBase.start(), edm::service::ConcurrentModuleTimer.start(), MyWatcher.start(), cmsPerfSuite.PerfSuiteTimer.start, RawEventFileWriterForBU.start(), edm::StreamerFileWriter.start(), evf::RecoEventOutputModuleForFU< Consumer >.start(), l1t::Interval< TimeType, PayloadType >.start(), evf::RecoEventWriterForFU.start(), Vispa.Main.RotatingIcon.RotatingIcon.start(), cond::persistency::Transaction.start(), edm::WallclockTimer.start(), Mapper::definition< ScannerT >.start(), DDAlgo.start(), hlt::CPUTimer.start(), edm::CPUTimer.start(), edm::RegionIndex< T >.start(), StripCompactDigiSimLinks::TrackRecord.start, Vispa.Share.ThreadChain.ThreadChain.start(), AlgoPos.start(), evf::EvFBuildingThrottle.start(), SiStripMonitorCluster::ClusterProperties.start, evf::FastMonitoringThread.start(), DQMNet.start(), cond::CSScopedSession.start(), SpecParParser::definition< ScannerT >.start(), cond::persistency::TransactionScope.start(), Types.LuminosityBlockRange.start(), PhysicsTools::VarProcessor::ValueIterator.start, esMonitoring.FDOutputListener.start, Types.EventRange.start(), progressbar.ProgressBar.start(), svgfig.LineAxis.start, looper.Looper.start_time, progressbar.ProgressBar.start_time, DDDWorldObserver< Event >.update(), PixelTrackFilterByKinematics.update(), PixelTrackFilter.update(), SaveSimTrack.update(), KillSecondariesRunAction.update(), KillSecondariesTrackAction.update(), GenericMVAComputerCache.update(), HIProtoTrackFilter.update(), Basic2DGenericPFlowClusterizer.update(), PFMultiDepthClusterizer.update(), reco::KalmanGhostTrackUpdater.update(), KalmanAlignmentMetricsUpdator.update(), PrintTrackNumberAction.update(), HIPixelTrackFilter.update(), SimpleMetricsUpdator.update(), PFlow2DClusterizerWithTime.update(), LagrangeChildUpdator.update(), VertexTrackUpdator< N >.update(), DummyVertexTrackUpdator< N >.update(), MultiMetricsUpdator.update(), FastFedCablingTask.update(), TrajectoryStateUpdator.update(), edm::RunningAverage.update(), MSLayersAtAngle.update(), ErrorCorrelation.update(), ApvTimingTask.update(), DaqScopeModeTask.update(), FedTimingTask.update(), DDG4ProductionCuts.update(), VpspScanTask.update(), ApvTimingHistosUsingDb.update(), NoiseHistosUsingDb.update(), OptoScanHistosUsingDb.update(), PedestalsHistosUsingDb.update(), PedsFullNoiseHistosUsingDb.update(), PedsOnlyHistosUsingDb.update(), VpspScanHistosUsingDb.update(), DummyMetricsUpdator.update(), OptoScanTask.update(), PedestalsTask.update(), GsfMultiStateUpdator.update(), MonopoleSteppingAction.update(), CalibrationScanTask.update(), CalibrationTask.update(), FineDelayTask.update(), LatencyTask.update(), SCRegressionCalculator< VarCalc >.update(), FastFedCablingHistosUsingDb.update(), CurrentAlignmentKFUpdator.update(), RHStopTracer.update(), cond::persistency::ITagTable.update(), PFClusterEnergyCorrectorBase.update(), PFCPositionCalculatorBase.update(), ValidHitPairFilter.update(), PrintSensitive.update(), SamplingHistosUsingDb.update(), FedCablingTask.update(), KFStrip1DUpdator.update(), LatencyHistosUsingDb.update(), TkPixelMeasurementDet.update(), CalibrationHistosUsingDb.update(), NoiseTask.update(), PedsOnlyTask.update(), ChildUpdator.update(), FineDelayHistosUsingDb.update(), PrintGeomInfoAction.update(), PrintMaterialBudgetInfo.update(), CountProcessesAction.update(), PedsFullNoiseTask.update(), PrintGeomMatInfo.update(), progressbar.Widget.update(), PhysicsTools::MVAComputerCache.update(), BaselinePFSCRegression.update(), ora::PVectorUpdater.update(), ClusterShapeTrackFilter.update(), KinematicConstrainedVertexUpdator.update(), KFSwitching1DUpdator.update(), cond::persistency::GLOBAL_TAG::Table.update(), StoreSecondary.update(), MuonServiceProxy.update(), BinomialProbability.update(), TrackingMaterialProducer.update(), GraphPath< N, E >.update(), cond::persistency::TAG::Table.update(), funct::Master< F >.update(), GflashG4Watcher.update(), PFClusterBuilderBase.update(), Observer< T >.update(), KFUpdator.update(), HcaluLUTTPGCoder.update(), CheckSecondary.update(), pat::CandidateSummaryTable::Record.update(), KalmanVertexTrackUpdator< N >.update(), edm::service::CondorStatusService.update(), ECAL2DPositionCalcWithDepthCorr.update(), CaloTrkProcessing.update(), pos::PixelConfig.update(), ora::IRelationalUpdater.update(), SiTrackerMultiRecHitUpdator.update(), BasicMultiTrajectoryState.update(), FWJobMetadataManager.update(), PhysicsTools::TreeReader.update(), TrackingVerboseAction.update(), HcalTestAnalysis.update(), SiStripConfObject.update(), SingleParticleEvent.update(), KalmanAlignmentUserVariables.update(), reco::GhostTrackFitter::PredictionUpdater.update(), ora::QueryableVectorUpdater.update(), FiberSD.update(), KalmanVertexUpdator< N >.update(), SiStripPartition.update(), fwlite::RecordWriter.update(), MuonTrajectoryUpdator.update(), FWParameterSetterBase.update(), KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >.update(), TotemTestGem.update(), progressbar.Timer.update(), MuonUpdatorAtVertex.update(), PltSD.update(), Bcm1fSD.update(), simwatcher::BeginOfTrackCounter.update(), DQMOldReceiver.update(), TkAccumulatingSensitiveDetector.update(), ora::OraPtrUpdater.update(), cond::persistency::OraTagTable.update(), HcalTB02Analysis.update(), LaserAlignmentSimulation.update(), ora::PrimitiveUpdater.update(), InitialClusteringStepBase.update(), ora::UniqueRefUpdater.update(), ora::OraReferenceUpdater.update(), ora::CArrayUpdater.update(), HcalTB06Analysis.update(), TotemSD.update(), ApvAnalysisFactory.update(), ora::ObjectUpdater.update(), progressbar.WidgetHFill.update(), ora::BlobUpdater.update(), HcalForwardAnalysis.update(), SimTracer.update(), MuonSensitiveDetector.update(), ora::InlineCArrayUpdater.update(), DTSegmentUpdator.update(), DTVDriftCalibration::cellInfo.update(), sistrip::RawToDigiUnpacker.update(), DAClusterizerInZ.update(), ora::STLContainerUpdater.update(), HcalTB04Analysis.update(), sim_act::Signaler< T >.update(), EcalTBH4Trigger.update(), DoCastorAnalysis.update(), ora::NamedRefUpdater.update(), ZdcTestAnalysis.update(), CastorTestAnalysis.update(), PhysicsTools::TreeReader::Value.update(), CaloSD.update(), QuadrupletSeedMerger.update(), BscSD.update(), edm::service::SimpleMemoryCheck.update(), DynamicTruncation.update(), cond::persistency::IPayloadMigrationTable.update(), PhysicsTools::MVAModuleHelper< Record, Object, Filler >::Value.update(), BetafuncEvtVtxGenerator.update(), evf::FastMonitoringService::Encoding.update(), ora::Container.update(), progressbar.Bar.update(), edm::BMixingModule.update(), FP420SD.update(), jsoncollector::IntJ.update(), HLTScalersClient::CountLSFifo_t.update(), progressbar.BouncingBar.update(), PFECALSuperClusterAlgo.update(), cond::persistency::IGTTable.update(), GaussianSumUtilities1D.update(), edmNew::DetSetVector< T >::IterHelp.update, CastorShowerLibraryMaker.update(), StandAloneMuonFilter.update(), DTRecSegment2D.update(), ora::Database.update(), MonitorElement.update(), jsoncollector::DoubleJ.update(), FWPSetTableManager.update(), DQMNet::Peer.update, CommissioningTask.update(), cond::persistency::OraGTTable.update(), progressbar.FormatLabel.update(), G4StepStatistics.update(), DQMNet::AutoPeer.update, TrajectoryStateOnSurface.update(), python.seqvaluedict.seqdict.update(), FWLiteESRecordWriterAnalyzer.update(), StMeasurementDetSet.update(), Folder.update(), cond::persistency::PAYLOAD_MIGRATION::Table.update(), FP420Test.update(), DAClusterizerInZ_vect.update(), BscTest.update(), jsoncollector::StringJ.update(), jsoncollector::HistoJ< T >.update(), BasicTrajectoryState.update(), progressbar.ProgressBar.update(), PxMeasurementDetSet.update(), and edmNew::DetSetVector< T >.update().

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

Definition at line 280 of file progressbar.py.

References progressbar.ProgressBar._DEFAULT_TERMSIZE.

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

Definition at line 327 of file progressbar.py.

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

328  def _format_line(self):
329  'Joins the widgets and justifies the line'
330 
331  widgets = ''.join(self._format_widgets())
332 
333  if self.left_justify: return widgets.ljust(self.term_width)
334  else: return widgets.rjust(self.term_width)
335 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def progressbar.ProgressBar._format_widgets (   self)
private

Definition at line 300 of file progressbar.py.

References progressbar.format_updatable(), bookConverter.max, progressbar.ProgressBar.term_width, progressbar.ProgressBar.update(), and progressbar.ProgressBar.widgets.

Referenced by progressbar.ProgressBar._format_line().

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

Definition at line 286 of file progressbar.py.

References progressbar.ProgressBar.fd, and progressbar.ProgressBar.term_width.

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

Definition at line 336 of file progressbar.py.

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().

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

Definition at line 344 of file progressbar.py.

345  def _update_widgets(self):
346  'Checks all widgets for the time sensitive bit'
348  self._time_sensitive = any(getattr(w, 'TIME_SENSITIVE', False)
349  for w in self.widgets)
350 
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:34
def progressbar.ProgressBar.finish (   self)

Definition at line 403 of file progressbar.py.

References progressbar.ProgressBar.finished, progressbar.ProgressBar.maxval, progressbar.ProgressBar.signal_set, DDDWorldObserver< Event >.update(), PixelTrackFilterByKinematics.update(), SaveSimTrack.update(), PixelTrackFilter.update(), KillSecondariesRunAction.update(), KillSecondariesTrackAction.update(), reco::KalmanGhostTrackUpdater.update(), KalmanAlignmentMetricsUpdator.update(), PrintTrackNumberAction.update(), HIProtoTrackFilter.update(), GenericMVAComputerCache.update(), Basic2DGenericPFlowClusterizer.update(), PFMultiDepthClusterizer.update(), SimpleMetricsUpdator.update(), HIPixelTrackFilter.update(), LagrangeChildUpdator.update(), VertexTrackUpdator< N >.update(), DummyVertexTrackUpdator< N >.update(), MultiMetricsUpdator.update(), TrajectoryStateUpdator.update(), FastFedCablingTask.update(), PFlow2DClusterizerWithTime.update(), FedTimingTask.update(), MSLayersAtAngle.update(), ErrorCorrelation.update(), VpspScanTask.update(), edm::RunningAverage.update(), DDG4ProductionCuts.update(), ApvTimingTask.update(), DaqScopeModeTask.update(), OptoScanTask.update(), PedestalsTask.update(), ApvTimingHistosUsingDb.update(), NoiseHistosUsingDb.update(), GsfMultiStateUpdator.update(), OptoScanHistosUsingDb.update(), PedestalsHistosUsingDb.update(), PedsFullNoiseHistosUsingDb.update(), PedsOnlyHistosUsingDb.update(), VpspScanHistosUsingDb.update(), DummyMetricsUpdator.update(), FineDelayTask.update(), LatencyTask.update(), MonopoleSteppingAction.update(), CalibrationScanTask.update(), CalibrationTask.update(), cond::persistency::ITagTable.update(), RHStopTracer.update(), FastFedCablingHistosUsingDb.update(), SCRegressionCalculator< VarCalc >.update(), CurrentAlignmentKFUpdator.update(), PFClusterEnergyCorrectorBase.update(), PFCPositionCalculatorBase.update(), ValidHitPairFilter.update(), FedCablingTask.update(), PrintSensitive.update(), SamplingHistosUsingDb.update(), KFStrip1DUpdator.update(), LatencyHistosUsingDb.update(), NoiseTask.update(), PedsOnlyTask.update(), CalibrationHistosUsingDb.update(), TkPixelMeasurementDet.update(), ChildUpdator.update(), FineDelayHistosUsingDb.update(), PedsFullNoiseTask.update(), CountProcessesAction.update(), PrintGeomInfoAction.update(), PrintMaterialBudgetInfo.update(), PrintGeomMatInfo.update(), progressbar.Widget.update(), KinematicConstrainedVertexUpdator.update(), ora::PVectorUpdater.update(), cond::persistency::GLOBAL_TAG::Table.update(), PhysicsTools::MVAComputerCache.update(), KFSwitching1DUpdator.update(), BaselinePFSCRegression.update(), ClusterShapeTrackFilter.update(), BinomialProbability.update(), StoreSecondary.update(), MuonServiceProxy.update(), TrackingMaterialProducer.update(), GraphPath< N, E >.update(), cond::persistency::TAG::Table.update(), GflashG4Watcher.update(), Observer< T >.update(), funct::Master< F >.update(), PFClusterBuilderBase.update(), KFUpdator.update(), CheckSecondary.update(), HcaluLUTTPGCoder.update(), KalmanVertexTrackUpdator< N >.update(), pat::CandidateSummaryTable::Record.update(), CaloTrkProcessing.update(), edm::service::CondorStatusService.update(), ECAL2DPositionCalcWithDepthCorr.update(), pos::PixelConfig.update(), SiTrackerMultiRecHitUpdator.update(), ora::IRelationalUpdater.update(), FWJobMetadataManager.update(), BasicMultiTrajectoryState.update(), HcalTestAnalysis.update(), TrackingVerboseAction.update(), PhysicsTools::TreeReader.update(), SiStripConfObject.update(), reco::GhostTrackFitter::PredictionUpdater.update(), KalmanVertexUpdator< N >.update(), SingleParticleEvent.update(), KalmanAlignmentUserVariables.update(), ora::QueryableVectorUpdater.update(), FiberSD.update(), fwlite::RecordWriter.update(), SiStripPartition.update(), MuonTrajectoryUpdator.update(), FWParameterSetterBase.update(), KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >.update(), TotemTestGem.update(), progressbar.Timer.update(), Bcm1fSD.update(), PltSD.update(), simwatcher::BeginOfTrackCounter.update(), MuonUpdatorAtVertex.update(), DQMOldReceiver.update(), TkAccumulatingSensitiveDetector.update(), ora::OraPtrUpdater.update(), HcalTB02Analysis.update(), LaserAlignmentSimulation.update(), cond::persistency::OraTagTable.update(), InitialClusteringStepBase.update(), ora::PrimitiveUpdater.update(), ora::UniqueRefUpdater.update(), ora::OraReferenceUpdater.update(), ora::CArrayUpdater.update(), ApvAnalysisFactory.update(), TotemSD.update(), HcalTB06Analysis.update(), ora::ObjectUpdater.update(), progressbar.WidgetHFill.update(), MuonSensitiveDetector.update(), HcalForwardAnalysis.update(), SimTracer.update(), ora::BlobUpdater.update(), DTSegmentUpdator.update(), ora::InlineCArrayUpdater.update(), DTVDriftCalibration::cellInfo.update(), sistrip::RawToDigiUnpacker.update(), DAClusterizerInZ.update(), ora::STLContainerUpdater.update(), HcalTB04Analysis.update(), sim_act::Signaler< T >.update(), EcalTBH4Trigger.update(), DoCastorAnalysis.update(), ora::NamedRefUpdater.update(), CastorTestAnalysis.update(), ZdcTestAnalysis.update(), PhysicsTools::TreeReader::Value.update(), CaloSD.update(), QuadrupletSeedMerger.update(), BscSD.update(), edm::service::SimpleMemoryCheck.update(), cond::persistency::IPayloadMigrationTable.update(), DynamicTruncation.update(), BetafuncEvtVtxGenerator.update(), PhysicsTools::MVAModuleHelper< Record, Object, Filler >::Value.update(), evf::FastMonitoringService::Encoding.update(), ora::Container.update(), progressbar.Bar.update(), edm::BMixingModule.update(), FP420SD.update(), jsoncollector::IntJ.update(), HLTScalersClient::CountLSFifo_t.update(), progressbar.BouncingBar.update(), PFECALSuperClusterAlgo.update(), cond::persistency::IGTTable.update(), GaussianSumUtilities1D.update(), edmNew::DetSetVector< T >::IterHelp.update, CastorShowerLibraryMaker.update(), StandAloneMuonFilter.update(), DTRecSegment2D.update(), ora::Database.update(), MonitorElement.update(), jsoncollector::DoubleJ.update(), DQMNet::Peer.update, FWPSetTableManager.update(), CommissioningTask.update(), cond::persistency::OraGTTable.update(), progressbar.FormatLabel.update(), G4StepStatistics.update(), DQMNet::AutoPeer.update, TrajectoryStateOnSurface.update(), python.seqvaluedict.seqdict.update(), FWLiteESRecordWriterAnalyzer.update(), StMeasurementDetSet.update(), Folder.update(), cond::persistency::PAYLOAD_MIGRATION::Table.update(), FP420Test.update(), DAClusterizerInZ_vect.update(), BscTest.update(), jsoncollector::StringJ.update(), jsoncollector::HistoJ< T >.update(), BasicTrajectoryState.update(), progressbar.ProgressBar.update(), PxMeasurementDetSet.update(), and edmNew::DetSetVector< T >.update().

Referenced by progressbar.ProgressBar.__next__().

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

Definition at line 293 of file progressbar.py.

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

294  def percentage(self):
295  'Returns the progress as a percentage.'
296  return self.currval * 100.0 / self.maxval
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.

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

Referenced by progressbar.ProgressBar.__next__().

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

Definition at line 351 of file progressbar.py.

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__(), relval_steps.Matrix.__setitem__(), relval_steps.Steps.__setitem__(), progressbar.ProgressBar._format_widgets(), Vispa.Gui.VispaWidget.VispaWidget.autosize(), Vispa.Views.LineDecayView.LineDecayContainer.createObject(), Vispa.Views.LineDecayView.LineDecayContainer.deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner.deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget.enableAutosizing(), progressbar.ProgressBar.finish(), Vispa.Gui.MenuWidget.MenuWidget.leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner.mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget.mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer.mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner.mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer.objectMoved(), relval_steps.Steps.overwrite(), Vispa.Views.LineDecayView.LineDecayContainer.removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget.removePorts(), Vispa.Gui.FindDialog.FindDialog.reset(), Vispa.Gui.PortConnection.PointToPointConnection.select(), Vispa.Gui.VispaWidget.VispaWidget.select(), Vispa.Views.LineDecayView.LineDecayContainer.select(), Vispa.Gui.VispaWidget.VispaWidget.setText(), Vispa.Gui.VispaWidget.VispaWidget.setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget.setZoom(), Vispa.Views.LineDecayView.LineDecayContainer.setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection.updateConnection().

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

Member Data Documentation

progressbar.ProgressBar.__iterable
private

Definition at line 236 of file progressbar.py.

Referenced by progressbar.ProgressBar.__call__(), and progressbar.ProgressBar.__next__().

tuple progressbar.ProgressBar.__slots__
staticprivate
Initial value:
1 = ('currval', 'fd', 'finished', 'last_update_time',
2  'left_justify', 'maxval', 'next_update', 'num_intervals',
3  'poll', 'seconds_elapsed', 'signal_set', 'start_time',
4  'term_width', 'update_interval', 'widgets', '_time_sensitive',
5  '__iterable')

Definition at line 206 of file progressbar.py.

int progressbar.ProgressBar._DEFAULT_MAXVAL = 100
staticprivate

Definition at line 212 of file progressbar.py.

Referenced by progressbar.ProgressBar.start().

int progressbar.ProgressBar._DEFAULT_TERMSIZE = 80
staticprivate

Definition at line 213 of file progressbar.py.

Referenced by progressbar.ProgressBar._env_size().

progressbar.ProgressBar._time_sensitive
private

Definition at line 347 of file progressbar.py.

Referenced by progressbar.ProgressBar._need_update().

progressbar.ProgressBar.currval

Definition at line 238 of file progressbar.py.

Referenced by progressbar.ProgressBar.__next__(), progressbar.ProgressBar._need_update(), progressbar.ProgressBar.percentage(), and progressbar.ProgressBar.update().

progressbar.ProgressBar.fd

Definition at line 221 of file progressbar.py.

Referenced by progressbar.ProgressBar._handle_resize().

progressbar.ProgressBar.finished

Definition at line 239 of file progressbar.py.

Referenced by progressbar.ProgressBar._need_update(), and progressbar.ProgressBar.finish().

progressbar.ProgressBar.last_update_time

Definition at line 240 of file progressbar.py.

Referenced by progressbar.ProgressBar._need_update().

progressbar.ProgressBar.left_justify

Definition at line 222 of file progressbar.py.

Referenced by progressbar.ProgressBar._format_line().

progressbar.ProgressBar.maxval

Definition at line 219 of file progressbar.py.

Referenced by progressbar.ProgressBar.__call__(), progressbar.ProgressBar.finish(), progressbar.ProgressBar.percentage(), progressbar.ProgressBar.start(), and progressbar.ProgressBar.update().

progressbar.ProgressBar.next = __next__
static

Definition at line 277 of file progressbar.py.

Referenced by progressbar.ProgressBar.__next__(), and BeautifulSoup.PageElement._invert().

progressbar.ProgressBar.next_update

Definition at line 369 of file progressbar.py.

Referenced by progressbar.ProgressBar._need_update().

progressbar.ProgressBar.num_intervals

Definition at line 389 of file progressbar.py.

progressbar.ProgressBar.poll

Definition at line 241 of file progressbar.py.

Referenced by progressbar.ProgressBar._need_update().

progressbar.ProgressBar.seconds_elapsed

Definition at line 242 of file progressbar.py.

Referenced by progressbar.ProgressBar.update().

progressbar.ProgressBar.signal_set

Definition at line 224 of file progressbar.py.

Referenced by progressbar.ProgressBar.finish().

progressbar.ProgressBar.start_time

Definition at line 243 of file progressbar.py.

Referenced by progressbar.ProgressBar.__next__(), and progressbar.ProgressBar.update().

progressbar.ProgressBar.term_width

Definition at line 226 of file progressbar.py.

Referenced by progressbar.ProgressBar._format_line(), progressbar.ProgressBar._format_widgets(), and progressbar.ProgressBar._handle_resize().

progressbar.ProgressBar.update_interval

Definition at line 244 of file progressbar.py.

progressbar.ProgressBar.widgets

Definition at line 220 of file progressbar.py.

Referenced by progressbar.ProgressBar._format_widgets(), Vispa.Views.BoxDecayView.BoxDecayView.collapseAll(), Vispa.Views.BoxDecayView.BoxDecayView.expandAll(), and Vispa.Views.BoxDecayView.BoxDecayView.expandToDepth().

Property Documentation

progressbar.ProgressBar.percent = property(percentage)
static

Definition at line 297 of file progressbar.py.