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


Python progressbar.Percentage方法代码示例

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


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

示例1: show_progress

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [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: _update_progress

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def _update_progress(self, percentage, **kwargs):
        """
        Update the progress with a percentage, including updating the progressbar as well as calling the progress
        callback.

        :param float percentage:    Percentage of the progressbar. from 0.0 to 100.0.
        :param kwargs:              Other parameters that will be passed to the progress_callback handler.
        :return: None
        """

        if self._show_progressbar:
            if self._progressbar is None:
                self._initialize_progressbar()

            self._progressbar.update(percentage * 10000)

        if self._progress_callback is not None:
            self._progress_callback(percentage, **kwargs)  # pylint:disable=not-callable 
开发者ID:angr,项目名称:angr,代码行数:20,代码来源:analysis.py

示例3: download

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def download(url, dst_file_path):
    # Download a file, showing progress
    bar_wrap = [None]

    def reporthook(count, block_size, total_size):
        bar = bar_wrap[0]
        if bar is None:
            bar = progressbar.ProgressBar(
                maxval=total_size,
                widgets=[
                    progressbar.Percentage(),
                    ' ',
                    progressbar.Bar(),
                    ' ',
                    progressbar.FileTransferSpeed(),
                    ' | ',
                    progressbar.ETA(),
                ])
            bar.start()
            bar_wrap[0] = bar
        bar.update(min(count * block_size, total_size))

    request.urlretrieve(url, dst_file_path, reporthook=reporthook) 
开发者ID:chainer,项目名称:chainer,代码行数:25,代码来源:download.py

示例4: deleteHostsByHostgroup

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def deleteHostsByHostgroup(groupname):
    hostgroup = zapi.hostgroup.get(output=['groupid'],filter={'name': groupname})
    if hostgroup.__len__() != 1:
        logger.error('Hostgroup not found: %s\n\tFound this: %s' % (groupname,hostgroup))
    groupid = int(hostgroup[0]['groupid'])
    hosts = zapi.host.get(output=['name','hostid'],groupids=groupid)
    total = len(hosts)
    logger.info('Hosts found: %d' % (total))
    if ( args.run ):
        x = 0
        bar = ProgressBar(maxval=total,widgets=[Percentage(), ReverseBar(), ETA(), RotatingMarker(), Timer()]).start()
        logger.echo = False
        for host in hosts:
            x = x + 1
            bar.update(x)
            logger.debug('(%d/%d) >> Removing >> %s' % (x, total, host))
            out = zapi.globo.deleteMonitors(host['name'])
        bar.finish()
        logger.echo = True
    else:
        logger.info('No host removed due to --no-run arg. Full list of hosts:')
        for host in hosts:
            logger.info('%s' % host['name'])
    return 
开发者ID:globocom,项目名称:zabbix-scripts,代码行数:26,代码来源:zbx_deleteMonitors.py

示例5: hosts_disable_all

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def hosts_disable_all():
  """
  status de host 0 = enabled
  status de host 1 = disabled
  """
  logger.info('Disabling all hosts, in blocks of 1000')
  hosts = zapi.host.get(output=[ 'hostid' ], search={ 'status': 0 })
  maxval = int(ceil(hosts.__len__())/1000+1)
  bar = ProgressBar(maxval=maxval,widgets=[Percentage(), ReverseBar(), ETA(), RotatingMarker(), Timer()]).start()
  i = 0
  for i in xrange(maxval):
    block = hosts[:1000]
    del hosts[:1000]
    result = zapi.host.massupdate(hosts=[ x for x in block ], status=1)
    i += 1
    bar.update(i)
  bar.finish()
  logger.info('Done')
  return 
开发者ID:globocom,项目名称:zabbix-scripts,代码行数:21,代码来源:zbx_clone.py

示例6: proxy_passive_to_active

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def proxy_passive_to_active():
  """
  status de prxy 5 = active
  status de prxy 6 = passive
  """
  logger.info('Change all proxys to active')
  proxys = zapi.proxy.get(output=[ 'shorten', 'host' ],
    filter={ 'status': 6 })
  if ( proxys.__len__() == 0 ):
    logger.info('Done')
    return
  bar = ProgressBar(maxval=proxys.__len__(),widgets=[Percentage(), ReverseBar(), ETA(), RotatingMarker(), Timer()]).start()
  i = 0
  for x in proxys:
    i += 1
    proxyid = x['proxyid']
    result = zapi.proxy.update(proxyid=proxyid, status=5)
    logger.echo = False
    logger.debug('Changed from passive to active proxy: %s' % (x['host']))
    bar.update(i)
  bar.finish()
  logger.echo = True
  logger.info('Done')
  return 
开发者ID:globocom,项目名称:zabbix-scripts,代码行数:26,代码来源:zbx_clone.py

示例7: create_bar

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [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

示例8: download_model

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def download_model(model):
    if model_in_cache(model): return
    model_url = get_model_url(model)
    tmp_zip = tempfile.NamedTemporaryFile(suffix=".zip")
    prompt = "Downloading model {}".format(model)
    def cb(count, block_size, total_size):
        global progress_bar
        if not progress_bar:
            widgets = [prompt, Percentage(), ' ', Bar(), ' ', FileTransferSpeed(), ' ', ETA()]
            progress_bar = ProgressBar(widgets=widgets, maxval=int(total_size)).start()
        progress_bar.update(min(total_size, count * block_size))
    urllib.urlretrieve(model_url, tmp_zip.name, cb)
    z = zipfile.ZipFile(tmp_zip)
    out_path = get_model_local_path(model)
    try:
        os.mkdir(out_path)
    except:
        pass
    for name in z.namelist():
        if name.startswith("_"): continue
        z.extract(name, out_path) 
开发者ID:agermanidis,项目名称:thingscoop,代码行数:23,代码来源:models.py

示例9: label_video

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def label_video(filename, classifier, sample_rate=1, recreate_index=False):
    index_filename = generate_index_path(filename, classifier.model)
    
    if os.path.exists(index_filename) and not recreate_index:
        return read_index_from_path(index_filename)
    
    temp_frame_dir, frames = extract_frames(filename, sample_rate=sample_rate)

    timed_labels = []

    widgets=["Labeling {}: ".format(filename), Percentage(), ' ', Bar(), ' ', ETA()]
    pbar = ProgressBar(widgets=widgets, maxval=len(frames)).start()

    for index, frame in enumerate(frames):
        pbar.update(index)
        labels = classifier.classify_image(frame)
        if not len(labels):
            continue
        t = (1./sample_rate) * index
        timed_labels.append((t, labels))
    
    shutil.rmtree(temp_frame_dir)
    save_index_to_path(index_filename, timed_labels)
    
    return timed_labels 
开发者ID:agermanidis,项目名称:thingscoop,代码行数:27,代码来源:search.py

示例10: save_best_overlap

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def save_best_overlap(val_bbox, output_bbox):

    progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()])
    count_best_bbox=0
    len_val_bbox=len(val_bbox)
    len_output_bbox=len(output_bbox)
    count_missing_boxes=0
    with open("best_overlap.txt", 'a') as d:
        for i in progress(range(0, len(val_bbox))):
            for rect in val_bbox[i].rects:
                if(len(output_bbox[i].rects)>0):
                    selected=multiclass_rectangle.pop_max_overlap(output_bbox[i].rects,rect)
                    count_best_bbox=count_best_bbox+1
                    d.write(str(val_bbox[i].frame)+' '+str(rect.label_chall)+ ' 0.5 '+str(selected.x1)+' '+str(selected.y1)+' '+str(selected.x2)+' '+str(selected.y2) + os.linesep)
                else:
                    count_missing_boxes=count_missing_boxes+1
    print "Total Frame Number: "+ str(len_val_bbox) 
    print "Total Output Bounding Boxes: "+ str(len_output_bbox) 
    print "Total Best Bounding Boxes: "+ str(count_best_bbox) 
    print "Total Missing Bounding Boxes: "+ str(count_missing_boxes) 
    print "Total False Positive Bounding Boxes: "+ str(len_output_bbox-count_best_bbox) 
    print "BBox/Frame Number: "+ str(float(count_best_bbox)/float(len_val_bbox)) 
    print "Missing BBox/Frame Number: "+ str(float(float(count_missing_boxes)/float(len_val_bbox)))
    print "False Positive BBox/Frame Number: "+ str(float(float(len_output_bbox-count_best_bbox)/float(len_val_bbox))) 
开发者ID:DrewNF,项目名称:Tensorflow_Object_Tracking_Video,代码行数:26,代码来源:eval_script.py

示例11: save_best_iou

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def save_best_iou(val_bbox, output_bbox):

    progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()])
    count_best_bbox=0
    len_val_bbox=len(val_bbox)
    len_output_bbox=len(output_bbox)
    count_missing_boxes=0
    with open("best_iou.txt", 'a') as d:
        for i in progress(range(0, len(val_bbox))):
            for rect in val_bbox[i].rects:
                if(len(output_bbox[i].rects)>0):
                    selected=multiclass_rectangle.pop_max_iou(output_bbox[i].rects,rect)
                    count_best_bbox=count_best_bbox+1
                    d.write(str(val_bbox[i].frame)+' '+str(rect.label_chall)+ ' 0.5 '+str(selected.x1)+' '+str(selected.y1)+' '+str(selected.x2)+' '+str(selected.y2) + os.linesep)
                else:
                    count_missing_boxes=count_missing_boxes+1
    print "Total Frame Number: "+ str(len_val_bbox) 
    print "Total Output Bounding Boxes: "+ str(len_output_bbox) 
    print "Total Best Bounding Boxes: "+ str(count_best_bbox) 
    print "Total Missing Bounding Boxes: "+ str(count_missing_boxes) 
    print "Total False Positive Bounding Boxes: "+ str(len_output_bbox-count_best_bbox) 
    print "BBox/Frame Number: "+ str(float(count_best_bbox)/float(len_val_bbox)) 
    print "Missing BBox/Frame Number: "+ str(float(float(count_missing_boxes)/float(len_val_bbox)))
    print "False Positive BBox/Frame Number: "+ str(float(float(len_output_bbox-count_best_bbox)/float(len_val_bbox))) 
开发者ID:DrewNF,项目名称:Tensorflow_Object_Tracking_Video,代码行数:26,代码来源:eval_script.py

示例12: make_tracked_video

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def make_tracked_video(out_vid_path, labeled_video_frames):

    if labeled_video_frames[0] is not None:

        img = cv2.imread(labeled_video_frames[0], True)
        print "Reading Filename: %s"%labeled_video_frames[0]
        h, w = img.shape[:2]
        print "Video Size: width: %d height: %d"%(h, w)
        fourcc = cv2.cv.CV_FOURCC('m', 'p', '4', 'v')
        out = cv2.VideoWriter(out_vid_path,fourcc, 20.0, (w, h), True)
        print("Start Making File Video:%s " % out_vid_path)
        print("%d Frames to Compress"%len(labeled_video_frames))
        progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()])
        for i in progress(range(0,len(labeled_video_frames))):
            if utils_image.check_image_with_pil(labeled_video_frames[i]):
                out.write(img)
                img = cv2.imread(labeled_video_frames[i], True)
        out.release()
        print("Finished Making File Video:%s " % out_vid_path) 
开发者ID:DrewNF,项目名称:Tensorflow_Object_Tracking_Video,代码行数:21,代码来源:Utils_Video.py

示例13: extract_frames

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def extract_frames(vid_path, video_perc):
    list=[]
    frames=[]
    # Opening & Reading the Video
    print("Opening File Video:%s " % vid_path)
    vidcap = cv2.VideoCapture(vid_path)
    if not vidcap.isOpened():
        print "could Not Open :",vid_path
        return
    print("Opened File Video:%s " % vid_path)
    print("Start Reading File Video:%s " % vid_path)
    image = vidcap.read()
    total = int((vidcap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT)/100)*video_perc)
    print("%d Frames to Read"%total)
    progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ',progressbar.Percentage(), ' ',progressbar.ETA()])
    for i in progress(range(0,total)):
        list.append("frame%d.jpg" % i)
        frames.append(image)
        image = vidcap.read()
    print("Finish Reading File Video:%s " % vid_path)
    return frames, list 
开发者ID:DrewNF,项目名称:Tensorflow_Object_Tracking_Video,代码行数:23,代码来源:Utils_Video.py

示例14: _init_progress_bar

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def _init_progress_bar(total_length, destination, message=None):
    if not message:
        message = "Downloading {!r}".format(os.path.basename(destination))

    valid_length = total_length and total_length > 0

    if valid_length and is_dumb_terminal():
        widgets = [message, " ", Percentage()]
        maxval = total_length
    elif valid_length and not is_dumb_terminal():
        widgets = [message, Bar(marker="=", left="[", right="]"), " ", Percentage()]
        maxval = total_length
    elif not valid_length and is_dumb_terminal():
        widgets = [message]
        maxval = UnknownLength
    else:
        widgets = [message, AnimatedMarker()]
        maxval = UnknownLength

    return ProgressBar(widgets=widgets, maxval=maxval) 
开发者ID:ubuntu,项目名称:microk8s,代码行数:22,代码来源:_windows.py

示例15: _get_progressbar_widgets

# 需要导入模块: import progressbar [as 别名]
# 或者: from progressbar import Percentage [as 别名]
def _get_progressbar_widgets(
    sim_index: Optional[int], timescale: TimeValue, know_stop_time: bool
) -> List[progressbar.widgets.WidgetBase]:
    widgets = []

    if sim_index is not None:
        widgets.append(f'Sim {sim_index:3}|')

    magnitude, units = timescale
    if magnitude == 1:
        sim_time_format = f'%(value)6.0f {units}|'
    else:
        sim_time_format = f'{magnitude}x%(value)6.0f {units}|'
    widgets.append(progressbar.FormatLabel(sim_time_format))

    widgets.append(progressbar.Percentage())

    if know_stop_time:
        widgets.append(progressbar.Bar())
    else:
        widgets.append(progressbar.BouncingBar())

    widgets.append(progressbar.ETA())

    return widgets 
开发者ID:SanDisk-Open-Source,项目名称:desmod,代码行数:27,代码来源:progress.py


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