Don't print twirl when stdout is redirected

Change-Id: Ieebf5471720904a60f3715cfb887100e8ab4628c
This commit is contained in:
Martin Magr
2013-02-25 18:53:57 +01:00
parent a799ec9754
commit 7b81fbe286

View File

@@ -106,10 +106,11 @@ def waitforpuppet(currently_running):
space_len = basedefs.SPACE_LEN - len(log_file) space_len = basedefs.SPACE_LEN - len(log_file)
if len(log_file) > log_len: if len(log_file) > log_len:
log_len = len(log_file) log_len = len(log_file)
twirl = twirl[-1:] + twirl[:-1] if sys.stdout.isatty():
sys.stdout.write(("\rTesting if puppet apply is finished : %s" % log_file).ljust(40 + log_len)) twirl = twirl[-1:] + twirl[:-1]
sys.stdout.write("[ %s ]" % twirl[0]) sys.stdout.write(("\rTesting if puppet apply is finished : %s" % log_file).ljust(40 + log_len))
sys.stdout.flush() sys.stdout.write("[ %s ]" % twirl[0])
sys.stdout.flush()
try: try:
# Once a remote puppet run has finished, we retrieve the log # Once a remote puppet run has finished, we retrieve the log
# file and check it for errors # file and check it for errors
@@ -124,7 +125,8 @@ def waitforpuppet(currently_running):
currently_running.remove((hostname, finished_logfile)) currently_running.remove((hostname, finished_logfile))
# clean off the last "testing apply" msg # 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: except ScriptRuntimeError, e:
# the test raises an exception if the file doesn't exist yet # the test raises an exception if the file doesn't exist yet