mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-03 01:18:00 +03:00
virtinstall: Hide total_size in the progress bar if it doesn't need
virt-install prints the total_size value to the progress bar even if it is meaningless. This value can be confusing to user, so for execute prosess that doesn't copy files (total_size = 0B), we hide the total_size value. For example, 'Creating domain...' doesn't need to print the total_size value. Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com> Signed-off-by: Haruka Ohata <ohata.haruka@fujitsu.com>
This commit is contained in:
parent
39c7a44314
commit
6ec00474a6
4
tests/data/meter/meter-zero.txt
Normal file
4
tests/data/meter/meter-zero.txt
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
Meter text test 100% [================] 0 B/s | 0 B --:-- ETA
|
||||
|
||||
Meter text test | 00:02
|
@ -224,6 +224,20 @@ def test_misc_meter():
|
||||
out = meter.output.getvalue().replace("\r", "\n")
|
||||
utils.diff_compare(out, os.path.join(utils.DATADIR, "meter", "meter6.txt"))
|
||||
|
||||
def _test_meter_zero(m, startval=0, text="Meter text test"):
|
||||
with unittest.mock.patch("time.time", return_value=1.0):
|
||||
m.start(text, startval)
|
||||
with unittest.mock.patch("time.time", return_value=3.0):
|
||||
m.update(0)
|
||||
with unittest.mock.patch("time.time", return_value=3.1):
|
||||
m.end()
|
||||
|
||||
# meter with size 0 and startval size 0
|
||||
meter = _progresspriv.TextMeter(output=io.StringIO())
|
||||
_test_meter_zero(meter, 0)
|
||||
out = meter.output.getvalue().replace("\r", "\n")
|
||||
utils.diff_compare(out, os.path.join(utils.DATADIR, "meter", "meter-zero.txt"))
|
||||
|
||||
# BaseMeter coverage
|
||||
meter = _progresspriv.BaseMeter()
|
||||
_test_meter_values(meter)
|
||||
|
@ -247,11 +247,15 @@ class TextMeter(BaseMeter):
|
||||
tl = TerminalLine(8)
|
||||
# For big screens, make it more readable.
|
||||
use_hours = bool(tl.llen > 80)
|
||||
ui_size = tl.add(' | %5sB' % total_size)
|
||||
ui_time = tl.add(' %s' % format_time(self.re.elapsed_time(),
|
||||
use_hours))
|
||||
ui_end, not_done = _term_add_end(tl, self.size, amount_read)
|
||||
dummy = not_done
|
||||
if not not_done and amount_read == 0:
|
||||
# Doesn't need to print total_size
|
||||
ui_size = tl.add(' | %5s ' % ' ')
|
||||
else:
|
||||
ui_size = tl.add(' | %5sB' % total_size)
|
||||
|
||||
out = '\r%-*.*s%s%s%s\n' % (tl.rest(), tl.rest(), self.text,
|
||||
ui_size, ui_time, ui_end)
|
||||
self.output.write(out)
|
||||
|
Loading…
Reference in New Issue
Block a user