52449cc01a
Now that we don't need to worry about python-2.4 and 2.5, we can make
some improvements to the way AnsiballZ handles modules.
* Change AnsiballZ wrapper to use import to invoke the module
We need the module to think of itself as a script because it could be
coded as:
main()
or as:
if __name__ == '__main__':
main()
Or even as:
if __name__ == '__main__':
random_function_name()
A script will invoke all of those. Prior to this change, we invoked
a second Python interpreter on the module so that it really was
a script. However, this means that we have to run python twice (once
for the AnsiballZ wrapper and once for the module). This change makes
the module think that it is a script (because __name__ in the module ==
'__main__') but it's actually being invoked by us importing the module
code.
There's three ways we've come up to do this.
* The most elegant is to use zipimporter and tell the import mechanism
that the module being loaded is __main__:
*
|
||
---|---|---|
.. | ||
__init__.py | ||
test__log_invocation.py | ||
test__symbolic_mode_to_octal.py | ||
test_argument_spec.py | ||
test_atomic_move.py | ||
test_deprecate_warn.py | ||
test_dict_converters.py | ||
test_exit_json.py | ||
test_filesystem.py | ||
test_get_file_attributes.py | ||
test_get_module_path.py | ||
test_heuristic_log_sanitize.py | ||
test_imports.py | ||
test_log.py | ||
test_no_log.py | ||
test_platform_distribution.py | ||
test_run_command.py | ||
test_safe_eval.py | ||
test_selinux.py | ||
test_set_mode_if_different.py | ||
test_tmpdir.py |