From a26c771bd90f7e3579446377237e44840c120e63 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 30 Jan 2017 15:16:15 -0500 Subject: [PATCH] fix cowsay for py3 --- lib/ansible/utils/display.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/utils/display.py b/lib/ansible/utils/display.py index c98b1eb17f..f1bc8d6745 100644 --- a/lib/ansible/utils/display.py +++ b/lib/ansible/utils/display.py @@ -84,7 +84,7 @@ class Display: try: cmd = subprocess.Popen([self.b_cowsay, "-l"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = cmd.communicate() - self.cows_available = set([ to_bytes(c) for c in out.split() ]) + self.cows_available = set([ to_text(c) for c in out.split() ]) if C.ANSIBLE_COW_WHITELIST: self.cows_available = set(C.ANSIBLE_COW_WHITELIST).intersection(self.cows_available) except: @@ -246,10 +246,10 @@ class Display: runcmd = [self.b_cowsay, b"-W", b"60"] if self.noncow: thecow = self.noncow - if thecow == b'random': - thecow = random.choice(self.cows_available) + if thecow == 'random': + thecow = random.choice(list(self.cows_available)) runcmd.append(b'-f') - runcmd.append(thecow) + runcmd.append(to_bytes(thecow)) runcmd.append(to_bytes(msg)) cmd = subprocess.Popen(runcmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = cmd.communicate()