From 6ec00474a659158f20248d6af3771d1a12ddac7b Mon Sep 17 00:00:00 2001 From: Toshiki Sonoda Date: Wed, 9 Nov 2022 18:33:57 +0900 Subject: 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 Signed-off-by: Haruka Ohata --- virtinst/_progresspriv.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'virtinst') diff --git a/virtinst/_progresspriv.py b/virtinst/_progresspriv.py index a035c9c4..207c6479 100644 --- a/virtinst/_progresspriv.py +++ b/virtinst/_progresspriv.py @@ -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) -- cgit v1.2.1