|
|
@ -24,7 +24,7 @@ import shlex
|
|
|
|
import subprocess
|
|
|
|
import subprocess
|
|
|
|
import select
|
|
|
|
import select
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.compat.six import PY2
|
|
|
|
from ansible.compat.six import PY2, PY3
|
|
|
|
from ansible.module_utils._text import to_bytes
|
|
|
|
from ansible.module_utils._text import to_bytes
|
|
|
|
|
|
|
|
|
|
|
|
def run_cmd(cmd, live=False, readsize=10):
|
|
|
|
def run_cmd(cmd, live=False, readsize=10):
|
|
|
@ -51,6 +51,10 @@ def run_cmd(cmd, live=False, readsize=10):
|
|
|
|
if p.stdout in rfd:
|
|
|
|
if p.stdout in rfd:
|
|
|
|
dat = os.read(p.stdout.fileno(), readsize)
|
|
|
|
dat = os.read(p.stdout.fileno(), readsize)
|
|
|
|
if live:
|
|
|
|
if live:
|
|
|
|
|
|
|
|
# On python3, stdout has a codec to go from text type to bytes
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdout.buffer.write(dat)
|
|
|
|
|
|
|
|
else:
|
|
|
|
sys.stdout.write(dat)
|
|
|
|
sys.stdout.write(dat)
|
|
|
|
stdout += dat
|
|
|
|
stdout += dat
|
|
|
|
if dat == b'':
|
|
|
|
if dat == b'':
|
|
|
@ -59,6 +63,10 @@ def run_cmd(cmd, live=False, readsize=10):
|
|
|
|
dat = os.read(p.stderr.fileno(), readsize)
|
|
|
|
dat = os.read(p.stderr.fileno(), readsize)
|
|
|
|
stderr += dat
|
|
|
|
stderr += dat
|
|
|
|
if live:
|
|
|
|
if live:
|
|
|
|
|
|
|
|
# On python3, stdout has a codec to go from text type to bytes
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdout.buffer.write(dat)
|
|
|
|
|
|
|
|
else:
|
|
|
|
sys.stdout.write(dat)
|
|
|
|
sys.stdout.write(dat)
|
|
|
|
if dat == b'':
|
|
|
|
if dat == b'':
|
|
|
|
rpipes.remove(p.stderr)
|
|
|
|
rpipes.remove(p.stderr)
|
|
|
|