When msger functions are called in an environment where the TTY supports
color, and the log messages begin with a carriage return (CR), then
message headers are formatted differently than they would be without the
CR.
For msger Info messages, it looks like:
\033[2K\033[32m\rInfo:\033[0m
and is interpreted as:
1. Clear the entire line
2. Change color code to 32
3. Print "\rInfo:"
4. Reset color code
This logic makes sense for messages that begin with a CR but do not end
with a newline, since TTYs on Linux will expect either a '\n' or a
'\r\n' combination. However, I don't see a situation where MIC needs to
log messages with the leading CR.
To avoid the above logic, remove the CR characters from existing log
messages so that newlines are always added when the messages are
printed.
Change-Id: Ib98ad1a7217033aeb1644098fea5b907d4f4729d
def start(self, filename, url, *args, **kwargs):
self.url = url
self.termwidth = terminal_width()
- msger.info("\r%-*s" % (self.termwidth, " "))
if self.total is None:
- msger.info("\rRetrieving %s ..." % truncate_url(self.url, self.termwidth - 15))
+ msger.info("Retrieving %s ..." % truncate_url(self.url, self.termwidth - 15))
else:
- msger.info("\rRetrieving %s [%d/%d] ..." % (truncate_url(self.url, self.termwidth - 25), self.counter, self.total))
+ msger.info("Retrieving %s [%d/%d] ..." % (truncate_url(self.url, self.termwidth - 25), self.counter, self.total))
def update(self, *args):
pass
fmt_bar = "%-" + width + "s"
if progress:
bar = fmt_bar % (self.mark * int(marks * (percent / 100.0)), )
- fmt = "\r %-10.10s: %-20.20s " + bar + " " + done
+ fmt = " %-10.10s: %-20.20s " + bar + " " + done
else:
bar = fmt_bar % (self.mark * marks, )
fmt = " %-10.10s: %-20.20s " + bar + " " + done