mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
078178f476
I thought tqdm was available everywhere, but it does not seem like it will be in RHEL9. Revert back to the old urlgrabber copy, now stored in virtinst/_progresspriv.py. If we ever want to try tqdm again, we can just revert this commit Signed-off-by: Cole Robinson <crobinso@redhat.com>
53 lines
1.1 KiB
Python
53 lines
1.1 KiB
Python
#
|
|
# Copyright 2021 Red Hat, Inc.
|
|
#
|
|
# This work is licensed under the GNU GPLv2 or later.
|
|
# See the COPYING file in the top-level directory.
|
|
#
|
|
|
|
import sys
|
|
|
|
from . import _progresspriv
|
|
|
|
|
|
class Meter:
|
|
"""
|
|
Meter class that hides the internals of the backend implementation
|
|
from virtinst and friends
|
|
"""
|
|
# Used by virt-manager subclass
|
|
format_number = _progresspriv.format_number
|
|
format_time = _progresspriv.format_time
|
|
|
|
def __init__(self, quiet=False):
|
|
self._text = None
|
|
self._size = None
|
|
self._total_read = 0
|
|
if quiet:
|
|
self._meter = _progresspriv.BaseMeter()
|
|
else:
|
|
self._meter = _progresspriv.TextMeter(output=sys.stdout)
|
|
|
|
def start(self, text, size):
|
|
self._text = text
|
|
self._size = size
|
|
self._total_read = 0
|
|
self._meter.start(text, size)
|
|
|
|
def update(self, new_total):
|
|
self._total_read = new_total
|
|
self._meter.update(new_total)
|
|
|
|
def end(self):
|
|
self._meter.end()
|
|
|
|
|
|
def make_meter(quiet):
|
|
return Meter(quiet=quiet)
|
|
|
|
|
|
def ensure_meter(meter):
|
|
if meter:
|
|
return meter
|
|
return make_meter(quiet=True)
|