Python progressbar.UnknownLength() Examples
The following are 16
code examples of progressbar.UnknownLength().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
progressbar
, or try the search function
.
Example #1
Source File: dataset.py From zhusuan with MIT License | 6 votes |
def show_progress(block_num, block_size, total_size): global pbar if pbar is None: if total_size > 0: prefixes = ('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi') power = min(int(math.log(total_size, 2) / 10), len(prefixes) - 1) scaled = float(total_size) / (2 ** (10 * power)) total_size_str = '{:.1f} {}B'.format(scaled, prefixes[power]) try: marker = '█' except UnicodeEncodeError: marker = '*' widgets = [ progressbar.Percentage(), ' ', progressbar.DataSize(), ' / ', total_size_str, ' ', progressbar.Bar(marker=marker), ' ', progressbar.ETA(), ' ', progressbar.AdaptiveTransferSpeed(), ] pbar = progressbar.ProgressBar(widgets=widgets, max_value=total_size) else: widgets = [ progressbar.DataSize(), ' ', progressbar.Bar(marker=progressbar.RotatingMarker()), ' ', progressbar.Timer(), ' ', progressbar.AdaptiveTransferSpeed(), ] pbar = progressbar.ProgressBar(widgets=widgets, max_value=progressbar.UnknownLength) downloaded = block_num * block_size if downloaded < total_size: pbar.update(downloaded) else: pbar.finish() pbar = None
Example #2
Source File: __init__.py From attention-lvcsr with MIT License | 6 votes |
def create_bar(self): """Create a new progress bar. Calls `self.get_iter_per_epoch()`, selects an appropriate set of widgets and creates a ProgressBar. """ iter_per_epoch = self.get_iter_per_epoch() epochs_done = self.main_loop.log.status['epochs_done'] if iter_per_epoch is None: widgets = ["Epoch {}, step ".format(epochs_done), progressbar.Counter(), ' ', progressbar.BouncingBar(), ' ', progressbar.Timer()] iter_per_epoch = progressbar.UnknownLength else: widgets = ["Epoch {}, step ".format(epochs_done), progressbar.Counter(), ' (', progressbar.Percentage(), ') ', progressbar.Bar(), ' ', progressbar.Timer(), ' ', progressbar.ETA()] return progressbar.ProgressBar(widgets=widgets, max_value=iter_per_epoch)
Example #3
Source File: inception_score.py From TAC-GAN with GNU General Public License v3.0 | 6 votes |
def prepare_inception_data(o_dir, i_dir): if not os.path.exists(o_dir): os.makedirs(o_dir) cnt = 0 bar = progressbar.ProgressBar(redirect_stdout=True, max_value=progressbar.UnknownLength) for root, subFolders, files in os.walk(i_dir): if files: for f in files: if 'jpg' in f: f_name = str(cnt) + '_ins.' + f.split('.')[-1] cnt += 1 file_dir = os.path.join(root, f) dest_path = os.path.join(o_dir, f) dest_new_name = os.path.join(o_dir, f_name) copy(file_dir, o_dir) os.rename(dest_path, dest_new_name) bar.update(cnt) bar.finish() print('Total number of files: {}'.format(cnt))
Example #4
Source File: inception_score.py From TAC-GAN with GNU General Public License v3.0 | 6 votes |
def load_images(o_dir, i_dir, n_images=3000, size=128): prepare_inception_data(o_dir, i_dir) image_list = [] done = False cnt = 0 bar = progressbar.ProgressBar(redirect_stdout=True, max_value=progressbar.UnknownLength) for root, dirs, files in os.walk(o_dir): if files: for f in files: cnt += 1 file_dir = os.path.join(root, f) image_list.append(ip.load_image_inception(file_dir, 0)) bar.update(cnt) if len(image_list) == n_images: done = True break if done: break bar.finish() print('Finished Loading Files') return image_list
Example #5
Source File: trajectory_HookClass.py From pySDC with BSD 2-Clause "Simplified" License | 6 votes |
def pre_run(self, step, level_number): """ Overwrite default routine called before time-loop starts Args: step: the current step level_number: the current level number """ super(trajectories, self).pre_run(step, level_number) # some abbreviations L = step.levels[level_number] if hasattr(L.prob.params, 'Tend'): self.bar_run = progressbar.ProgressBar(max_value=L.prob.params.Tend) else: self.bar_run = progressbar.ProgressBar(max_value=progressbar.UnknownLength)
Example #6
Source File: progress.py From desmod with MIT License | 6 votes |
def _get_standalone_pbar( env: 'SimEnvironment', max_width: int, fd: IO ) -> progressbar.ProgressBar: pbar = progressbar.ProgressBar( fd=fd, min_value=0, max_value=progressbar.UnknownLength, widgets=_get_progressbar_widgets( env.sim_index, env.timescale, know_stop_time=False ), ) if max_width and pbar.term_width > max_width: pbar.term_width = max_width return pbar
Example #7
Source File: diskover.py From diskover with Apache License 2.0 | 5 votes |
def progress_bar(event): if event == 'Checking' or event == 'Calculating': widgets = [progressbar.AnimatedMarker(), ' ', event + ' (Queue: ', progressbar.Counter(), ') ', progressbar.Timer()] bar = progressbar.ProgressBar(widgets=widgets, max_value=progressbar.UnknownLength) else: widgets = [event + ' ', progressbar.Bar(), progressbar.Percentage(), ' (', progressbar.Timer(), ', ', progressbar.ETA(), ')'] bar = progressbar.ProgressBar(widgets=widgets, max_value=100) return bar
Example #8
Source File: interfaces.py From HoneyBot with MIT License | 5 votes |
def learn(self, timeout=60): """ Builds a whitelist of IP addresses for every connection captured during this time-period :param timeout: The number of seconds to capture traffic """ src_ips = set() dst_ips = set() with open('ip.whitelist', 'w') as f: if not sys.warnoptions: warnings.simplefilter("ignore") print('Generating whitelist of IP addresses based on traffic from the next {} seconds.'.format(timeout)) bar = progressbar.ProgressBar(max_value=progressbar.UnknownLength) for conn in self.listener(timeout=timeout): try: src, dst, proto = conn if IP(src).iptype() == 'PUBLIC': src_ips.add(src) bar.update(len(src_ips) + len(dst_ips)) if IP(dst).iptype() == 'PUBLIC': dst_ips.add(dst) bar.update(len(src_ips) + len(dst_ips)) except AttributeError: pass all_ips = list(src_ips) all_ips.extend(dst_ips) all_ips = set(all_ips) for ip in all_ips: f.write(ip + '\n')
Example #9
Source File: _downloads.py From oggm with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _progress_urlretrieve(url, cache_name=None, reset=False, auth=None, timeout=None): """Downloads a file, returns its local path, and shows a progressbar.""" try: from progressbar import DataTransferBar, UnknownLength pbar = [None] def _upd(count, size, total): if pbar[0] is None: pbar[0] = DataTransferBar() if pbar[0].max_value is None: if total > 0: pbar[0].start(total) else: pbar[0].start(UnknownLength) pbar[0].update(min(count * size, total)) sys.stdout.flush() res = oggm_urlretrieve(url, cache_obj_name=cache_name, reset=reset, reporthook=_upd, auth=auth, timeout=timeout) try: pbar[0].finish() except BaseException: pass return res except (ImportError, ModuleNotFoundError): return oggm_urlretrieve(url, cache_obj_name=cache_name, reset=reset, auth=auth, timeout=timeout)
Example #10
Source File: ProgressManager.py From EventMonkey with Apache License 2.0 | 5 votes |
def __init__(self,interface_type,count=None,description=None): self.interface_type = interface_type self.current_value = 0 if self.interface_type == Config.UI_CLI: widgets = [] if description is not None: widgets.append('{}: '.format(description)) if count is not None: widgets.append(Percentage()) widgets.append(' ') widgets.append(Bar()) else: widgets.append(Counter()) widgets.append(' ') widgets.append(AnimatedMarker(markers='.oO@* ')) if count is not None: self.progressBar = ProgressBar(widgets=widgets, max_value=count) else: self.progressBar = ProgressBar(max_value=progressbar.UnknownLength,widgets=widgets) else: PROGRESS_LOGGER.error('interface type not handled: {}'.format(self.interface_type)) raise Exception('interface type not handled: {}'.format(self.interface_type))
Example #11
Source File: spiraling_particle_HookClass.py From pySDC with BSD 2-Clause "Simplified" License | 5 votes |
def pre_run(self, step, level_number): """ Overwrite standard pre run hook Args: step (pySDC.Step.step): the current step level_number (int): the current level number """ super(particles_output, self).pre_run(step, level_number) L = step.levels[0] if hasattr(L.prob.params, 'Tend'): self.bar_run = progressbar.ProgressBar(max_value=L.prob.params.Tend) else: self.bar_run = progressbar.ProgressBar(max_value=progressbar.UnknownLength)
Example #12
Source File: __init__.py From dnsbrute with MIT License | 5 votes |
def on_finish(self): if self.progress: try: self.progress.update(self.finished) except Exception: self.progress.update(progressbar.UnknownLength) self.finished += 1
Example #13
Source File: deployment_utils.py From hammr with Apache License 2.0 | 5 votes |
def show_deploy_progress_without_percentage(image_object, deployed_instance_id): printer.out("Deployment in progress", printer.INFO) status = image_object.api.Users(image_object.login).Deployments(Did=deployed_instance_id).Status.Getdeploystatus() bar = ProgressBar(widgets=[BouncingBar()], maxval=UnknownLength) bar.start() i = 1 while not (status.message == "running" or status.message == "on-fire"): status = image_object.api.Users(image_object.login).Deployments(Did=deployed_instance_id).Status.Getdeploystatus() time.sleep(1) bar.update(i) i += 2 bar.finish() return status
Example #14
Source File: penningtrap_HookClass.py From pySDC with BSD 2-Clause "Simplified" License | 4 votes |
def pre_run(self, step, level_number): """ Overwrite default routine called before time-loop starts Args: step: the current step level_number: the current level number """ super(particles_output, self).pre_run(step, level_number) # some abbreviations L = step.levels[level_number] if hasattr(L.prob.params, 'Tend'): self.bar_run = progressbar.ProgressBar(max_value=L.prob.params.Tend) else: self.bar_run = progressbar.ProgressBar(max_value=progressbar.UnknownLength) part = L.u[0] N = L.prob.params.nparts w = np.array([1, 1, -2]) # compute (slowly..) the potential at u0 fpot = np.zeros(N) for i in range(N): # inner loop, omit ith particle for j in range(0, i): dist2 = np.linalg.norm(part.pos.values[:, i] - part.pos.values[:, j], 2) ** 2 + L.prob.params.sig ** 2 fpot[i] += part.q[j] / np.sqrt(dist2) for j in range(i + 1, N): dist2 = np.linalg.norm(part.pos.values[:, i] - part.pos.values[:, j], 2) ** 2 + L.prob.params.sig ** 2 fpot[i] += part.q[j] / np.sqrt(dist2) fpot[i] -= L.prob.params.omega_E ** 2 * part.m[i] / part.q[i] / 2.0 * \ np.dot(w, part.pos.values[:, i] * part.pos.values[:, i]) # add up kinetic and potntial contributions to total energy epot = 0 ekin = 0 for n in range(N): epot += part.q[n] * fpot[n] ekin += part.m[n] / 2.0 * np.dot(part.vel.values[:, n], part.vel.values[:, n]) self.add_to_stats(process=step.status.slot, time=L.time, level=L.level_index, iter=0, sweep=L.status.sweep, type='etot', value=epot + ekin)
Example #15
Source File: utils.py From zget with MIT License | 4 votes |
def __call__(self, count, blocksize, totalsize): # In case we don't know the size of the file. zget < 0.9 did not # report file sizes via HTTP. if totalsize <= 0: if self.pbar is None: self.pbar = progressbar.ProgressBar( widgets=[ self.filename, ' ', progressbar.BouncingBar(), ' ', progressbar.FileTransferSpeed(), ], maxval=progressbar.UnknownLength ) self.pbar.start() # Make sure we have at least 1, otherwise the bar does not show # 100% for small transfers self.pbar.update(max(count * blocksize, 1)) # zget >= 0.9 does report file sizes and enables percentage and ETA # display. else: if self.pbar is None: self.pbar = progressbar.ProgressBar( widgets=[ self.filename, ' ', progressbar.Percentage(), ' ', progressbar.Bar(), ' ', progressbar.ETA(), ' ', progressbar.FileTransferSpeed(), ], # Make sure we have at least 1, otherwise the bar does # not show 100% for small transfers maxval=max(totalsize, 1) ) self.pbar.start() # Make sure we have at least 1, otherwise the bar does not show # 100% for small transfers self.pbar.update(max(min(count * blocksize, totalsize), 1))
Example #16
Source File: import_whisper.py From biggraphite with Apache License 2.0 | 4 votes |
def main(args=None): """Entry point for the module.""" if not args: args = sys.argv[1:] opts = _parse_opts(args) pool_factory = multiprocessing.Pool if opts.process == 1: pool_factory = multiprocessing_dummy.Pool pool = pool_factory(opts.process, initializer=_setup_process, initargs=(opts,)) out_fd = sys.stderr if opts.quiet: out_fd = _DEV_NULL if "__pypy__" not in sys.builtin_module_names: print("Running without PyPy, this is about 20 times slower", file=out_fd) out_fd.flush() walker = _Walker(opts.root_directory, opts.filter) paths = walker.paths() total_points = 0 max_value = progressbar.UnknownLength with progressbar.ProgressBar( max_value=max_value, fd=out_fd, redirect_stderr=True ) as pbar: try: res = pool.imap_unordered(_import_whisper, paths) for n_path, n_points in enumerate(res): total_points += n_points pbar.update(n_path) except KeyboardInterrupt: pool.terminate() pool.close() pool.join() print( "Uploaded", walker.count, "metrics containing", total_points, "points", file=out_fd, )