From 7b81fbe2869b1f0608f2849ad47127fa7b0e2b54 Mon Sep 17 00:00:00 2001 From: Martin Magr Date: Mon, 25 Feb 2013 18:53:57 +0100 Subject: [PATCH] Don't print twirl when stdout is redirected Change-Id: Ieebf5471720904a60f3715cfb887100e8ab4628c --- packstack/plugins/puppet_950.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packstack/plugins/puppet_950.py b/packstack/plugins/puppet_950.py index e597b9200..d22806974 100644 --- a/packstack/plugins/puppet_950.py +++ b/packstack/plugins/puppet_950.py @@ -106,10 +106,11 @@ def waitforpuppet(currently_running): space_len = basedefs.SPACE_LEN - len(log_file) if len(log_file) > log_len: log_len = len(log_file) - twirl = twirl[-1:] + twirl[:-1] - sys.stdout.write(("\rTesting if puppet apply is finished : %s" % log_file).ljust(40 + log_len)) - sys.stdout.write("[ %s ]" % twirl[0]) - sys.stdout.flush() + if sys.stdout.isatty(): + twirl = twirl[-1:] + twirl[:-1] + sys.stdout.write(("\rTesting if puppet apply is finished : %s" % log_file).ljust(40 + log_len)) + sys.stdout.write("[ %s ]" % twirl[0]) + sys.stdout.flush() try: # Once a remote puppet run has finished, we retrieve the log # file and check it for errors @@ -124,7 +125,8 @@ def waitforpuppet(currently_running): currently_running.remove((hostname, finished_logfile)) # clean off the last "testing apply" msg - sys.stdout.write(("\r").ljust(45 + log_len)) + if sys.stdout.isatty(): + sys.stdout.write(("\r").ljust(45 + log_len)) except ScriptRuntimeError, e: # the test raises an exception if the file doesn't exist yet