1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Allow cowsay to be removed mid playbook run.

This commit is contained in:
Michael DeHaan 2013-06-01 17:06:40 -04:00
parent 754d5f91a3
commit 4840e59b90

View file

@ -204,9 +204,8 @@ def regular_generic_msg(hostname, result, oneline, caption):
return "%s | %s >> %s\n" % (hostname, caption, utils.jsonify(result)) return "%s | %s >> %s\n" % (hostname, caption, utils.jsonify(result))
def banner(msg): def banner_cowsay(msg):
if cowsay:
if msg.find(": [") != -1: if msg.find(": [") != -1:
msg = msg.replace("[","") msg = msg.replace("[","")
if msg.endswith("]"): if msg.endswith("]"):
@ -219,13 +218,24 @@ def banner(msg):
cmd = subprocess.Popen(runcmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) cmd = subprocess.Popen(runcmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = cmd.communicate() (out, err) = cmd.communicate()
return "%s\n" % out return "%s\n" % out
else:
def banner_normal(msg):
width = 78 - len(msg) width = 78 - len(msg)
if width < 3: if width < 3:
width = 3 width = 3
filler = "*" * width filler = "*" * width
return "\n%s %s " % (msg, filler) return "\n%s %s " % (msg, filler)
def banner(msg):
if cowsay:
try:
return banner_cowsay(msg)
except OSError:
# somebody cleverly deleted cowsay or something during the PB run. heh.
return banner_normal(msg)
return banner_normal(msg)
def command_generic_msg(hostname, result, oneline, caption): def command_generic_msg(hostname, result, oneline, caption):
''' output the result of a command run ''' ''' output the result of a command run '''