From a4ca3823b9d2d152c5e7d833700124437ba17e91 Mon Sep 17 00:00:00 2001 From: Seblu <sebastien.luttringer@smartjog.com> Date: Wed, 31 Aug 2011 12:09:10 +0200 Subject: [PATCH] Print color only on a tty --- installsystems/printer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/installsystems/printer.py b/installsystems/printer.py index a262a05..d5926a1 100644 --- a/installsystems/printer.py +++ b/installsystems/printer.py @@ -47,7 +47,10 @@ def out(message="", fd=sys.stdout, endl=os.linesep, flush=True): ''' # color subsitution for c in color: - message = message.replace("#%s#" % c, color[c]) + if fd.isatty(): + message = message.replace("#%s#" % c, color[c]) + else: + message = message.replace("#%s#" % c, "") # printing fd.write("%s%s" % (message, endl)) if flush: -- GitLab