MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / TerminalProgressBar

Class TerminalProgressBar

pyxrf/core/map_processing.py:74–105  ·  view source on GitHub ↗

Custom class that displays the progress bar in the terminal. Progress is displayed in %. Unfortunately it works only in the terminal (or emulated terminal) and nothing will be printed in stderr if TTY is disabled. Examples -------- .. code-block:: python title = "M

Source from the content-addressed store, hash-verified

72
73
74class TerminalProgressBar:
75 """
76 Custom class that displays the progress bar in the terminal. Progress
77 is displayed in %. Unfortunately it works only in the terminal (or emulated
78 terminal) and nothing will be printed in stderr if TTY is disabled.
79
80 Examples
81 --------
82 .. code-block:: python
83
84 title = "Monitor progress"
85 pbar = TerminalProgressBar(title)
86 pbar.start()
87 for n in range(10):
88 pbar(n * 10) # Go from 0 to 90%
89 pbar.finish() # This should set it to 100%
90 """
91
92 def __init__(self, title):
93 self.title = title
94
95 def start(self):
96 self.bar = Bar(self.title, max=100, suffix="%(percent)d%%")
97
98 def __call__(self, percent_completed):
99 while self.bar.index < percent_completed:
100 self.bar.next()
101
102 def finish(self):
103 while self.bar.index < 100.0:
104 self.bar.next()
105 self.bar.finish()
106
107
108def wait_and_display_progress(fut, progress_bar=None):

Callers 6

test_TerminalProgressBarFunction · 0.90
get_spectrumMethod · 0.85
get_roi_sumMethod · 0.85

Calls

no outgoing calls