From ea2d00c5585a474b67f5031f689c143974eb9dc9 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 26 Mar 2015 11:57:27 -0700 Subject: [PATCH] v2 equivalent for https://github.com/ansible/ansible/pull/8564 Looks like there's currently no code for the ansible_*_interpreter but modified the note abouot adding it --- v2/ansible/executor/module_common.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/v2/ansible/executor/module_common.py b/v2/ansible/executor/module_common.py index 9f878fb6b0..7c76fd7427 100644 --- a/v2/ansible/executor/module_common.py +++ b/v2/ansible/executor/module_common.py @@ -165,23 +165,25 @@ def modify_module(module_path, module_args, strip_comments=False): # facility = inject['ansible_syslog_facility'] # module_data = module_data.replace('syslog.LOG_USER', "syslog.%s" % facility) - lines = module_data.split("\n", 1) + lines = module_data.split(b"\n", 1) shebang = None - if lines[0].startswith("#!"): + if lines[0].startswith(b"#!"): shebang = lines[0].strip() args = shlex.split(str(shebang[2:])) interpreter = args[0] interpreter_config = 'ansible_%s_interpreter' % os.path.basename(interpreter) # FIXME: more inject stuff here... + #from ansible.utils.unicode import to_bytes #if interpreter_config in inject: - # lines[0] = shebang = "#!%s %s" % (inject[interpreter_config], " ".join(args[1:])) + # interpreter = to_bytes(inject[interpreter_config], errors='strict') + # lines[0] = shebang = b"#!{0} {1}".format(interpreter, b" ".join(args[1:])) lines.insert(1, ENCODING_STRING) else: lines.insert(0, ENCODING_STRING) - module_data = "\n".join(lines) + module_data = b"\n".join(lines) return (module_data, module_style, shebang)