当前位置: 首页>>代码示例>>Python>>正文


Python progressbar.UnknownLength方法代码示例

本文整理汇总了Python中progressbar.UnknownLength方法的典型用法代码示例。如果您正苦于以下问题:Python progressbar.UnknownLength方法的具体用法?Python progressbar.UnknownLength怎么用?Python progressbar.UnknownLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在progressbar的用法示例。


在下文中一共展示了progressbar.UnknownLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show_progress

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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 
开发者ID:thu-ml,项目名称:zhusuan,代码行数:41,代码来源:dataset.py

示例2: create_bar

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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) 
开发者ID:rizar,项目名称:attention-lvcsr,代码行数:27,代码来源:__init__.py

示例3: prepare_inception_data

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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)) 
开发者ID:dashayushman,项目名称:TAC-GAN,代码行数:22,代码来源:inception_score.py

示例4: load_images

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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 
开发者ID:dashayushman,项目名称:TAC-GAN,代码行数:24,代码来源:inception_score.py

示例5: pre_run

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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) 
开发者ID:Parallel-in-Time,项目名称:pySDC,代码行数:18,代码来源:trajectory_HookClass.py

示例6: _get_standalone_pbar

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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 
开发者ID:SanDisk-Open-Source,项目名称:desmod,代码行数:18,代码来源:progress.py

示例7: progress_bar

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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 
开发者ID:shirosaidev,项目名称:diskover,代码行数:11,代码来源:diskover.py

示例8: learn

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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') 
开发者ID:PacketTotal,项目名称:HoneyBot,代码行数:33,代码来源:interfaces.py

示例9: _progress_urlretrieve

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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) 
开发者ID:OGGM,项目名称:oggm,代码行数:30,代码来源:_downloads.py

示例10: __init__

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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)) 
开发者ID:devgc,项目名称:EventMonkey,代码行数:28,代码来源:ProgressManager.py

示例11: pre_run

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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) 
开发者ID:Parallel-in-Time,项目名称:pySDC,代码行数:17,代码来源:spiraling_particle_HookClass.py

示例12: on_finish

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
def on_finish(self):
        if self.progress:
            try:
                self.progress.update(self.finished)
            except Exception:
                self.progress.update(progressbar.UnknownLength)
        self.finished += 1 
开发者ID:XiphosResearch,项目名称:dnsbrute,代码行数:9,代码来源:__init__.py

示例13: show_deploy_progress_without_percentage

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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 
开发者ID:usharesoft,项目名称:hammr,代码行数:16,代码来源:deployment_utils.py

示例14: pre_run

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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) 
开发者ID:Parallel-in-Time,项目名称:pySDC,代码行数:45,代码来源:penningtrap_HookClass.py

示例15: __call__

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import UnknownLength [as 别名]
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)) 
开发者ID:nils-werner,项目名称:zget,代码行数:49,代码来源:utils.py


注:本文中的progressbar.UnknownLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。