We've changed run_command to return native_strings

on python3, this means that we don't get bytes back by default.  We
probably do want bytes here so modify our call to run_command so we get
bytes instead of text.
pull/18777/head
Toshio Kuratomi 8 years ago committed by Matt Clay
parent b091d39baf
commit 283205d7b3

@ -97,13 +97,13 @@ EXAMPLES = '''
import datetime import datetime
import glob import glob
import re
import shlex import shlex
import os import os
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import b from ansible.module_utils.six import b
def check_command(commandline): def check_command(commandline):
arguments = { 'chown': 'owner', 'chmod': 'mode', 'chgrp': 'group', arguments = { 'chown': 'owner', 'chmod': 'mode', 'chgrp': 'group',
'ln': 'state=link', 'mkdir': 'state=directory', 'ln': 'state=link', 'mkdir': 'state=directory',
@ -144,9 +144,9 @@ def main():
shell = module.params['_uses_shell'] shell = module.params['_uses_shell']
chdir = module.params['chdir'] chdir = module.params['chdir']
executable = module.params['executable'] executable = module.params['executable']
args = module.params['_raw_params'] args = module.params['_raw_params']
creates = module.params['creates'] creates = module.params['creates']
removes = module.params['removes'] removes = module.params['removes']
warn = module.params['warn'] warn = module.params['warn']
if args.strip() == '': if args.strip() == '':
@ -169,9 +169,9 @@ def main():
) )
if removes: if removes:
# do not run the command if the line contains removes=filename # do not run the command if the line contains removes=filename
# and the filename does not exist. This allows idempotence # and the filename does not exist. This allows idempotence
# of command executions. # of command executions.
if not glob.glob(removes): if not glob.glob(removes):
module.exit_json( module.exit_json(
cmd=args, cmd=args,
@ -188,7 +188,7 @@ def main():
args = shlex.split(args) args = shlex.split(args)
startd = datetime.datetime.now() startd = datetime.datetime.now()
rc, out, err = module.run_command(args, executable=executable, use_unsafe_shell=shell) rc, out, err = module.run_command(args, executable=executable, use_unsafe_shell=shell, encoding=None)
endd = datetime.datetime.now() endd = datetime.datetime.now()
delta = endd - startd delta = endd - startd

Loading…
Cancel
Save