From 425b507b9050486ff679ffec70ff3ffe43bf422d Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Mon, 26 Aug 2013 10:45:45 -0700 Subject: [PATCH] Remove several CR chars in log messages 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 --- mic/utils/grabber.py | 5 ++--- mic/utils/rpmmisc.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mic/utils/grabber.py b/mic/utils/grabber.py index 45e30b4..306dfc5 100644 --- a/mic/utils/grabber.py +++ b/mic/utils/grabber.py @@ -79,11 +79,10 @@ class TextProgress(object): 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 diff --git a/mic/utils/rpmmisc.py b/mic/utils/rpmmisc.py index af15763..1c9287e 100644 --- a/mic/utils/rpmmisc.py +++ b/mic/utils/rpmmisc.py @@ -74,7 +74,7 @@ class RPMInstallCallback: 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 -- 2.7.4