diff --git a/mitogen/ansible/__init__.py b/ansible_mitogen/__init__.py similarity index 100% rename from mitogen/ansible/__init__.py rename to ansible_mitogen/__init__.py diff --git a/ansible_mitogen/action/__init__.py b/ansible_mitogen/action/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/mitogen/ansible/action.py b/ansible_mitogen/action/mitogen.py similarity index 97% rename from mitogen/ansible/action.py rename to ansible_mitogen/action/mitogen.py index 267344b2..fb6ce253 100644 --- a/mitogen/ansible/action.py +++ b/ansible_mitogen/action/mitogen.py @@ -31,7 +31,7 @@ import os import ansible import ansible.plugins import ansible.plugins.action.normal -import mitogen.ansible.helpers +import ansible_mitogen.helpers ANSIBLE_BASEDIR = os.path.dirname(ansible.__file__) @@ -57,7 +57,7 @@ class ActionModule(ansible.plugins.action.normal.ActionModule): ##################################################################### py_module_name = self.get_py_module_name(module_name) - js = self._connection.py_call(mitogen.ansible.helpers.run_module, py_module_name, + js = self._connection.py_call(ansible_mitogen.helpers.run_module, py_module_name, args=json.loads(json.dumps(module_args))) ##################################################################### diff --git a/ansible_mitogen/connection/__init__.py b/ansible_mitogen/connection/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/mitogen/ansible/connection.py b/ansible_mitogen/connection/mitogen.py similarity index 88% rename from mitogen/ansible/connection.py rename to ansible_mitogen/connection/mitogen.py index 21c41606..24642ebe 100644 --- a/mitogen/ansible/connection.py +++ b/ansible_mitogen/connection/mitogen.py @@ -42,12 +42,12 @@ Enable it by: EOF """ -import mitogen.master -import mitogen.unix -from mitogen.ansible import helpers +from __future__ import absolute_import import ansible.errors import ansible.plugins.connection +import ansible_mitogen.helpers +import mitogen.unix class Connection(ansible.plugins.connection.ConnectionBase): @@ -78,15 +78,15 @@ class Connection(ansible.plugins.connection.ConnectionBase): super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable) if in_data: raise ansible.errors.AnsibleError("does not support module pipelining") - return self.py_call(helpers.exec_command, cmd, in_data) + return self.py_call(ansible_mitogen.helpers.exec_command, cmd, in_data) def fetch_file(self, in_path, out_path): - output = self.py_call(helpers.read_path, in_path) - helpers.write_path(out_path, output) + output = self.py_call(ansible_mitogen.helpers.read_path, in_path) + ansible_mitogen.helpers.write_path(out_path, output) def put_file(self, in_path, out_path): - self.py_call(helpers.write_path, out_path, - helpers.read_path(in_path)) + self.py_call(ansible_mitogen.helpers.write_path, out_path, + ansible_mitogen.helpers.read_path(in_path)) def close(self): self.router.broker.shutdown() diff --git a/mitogen/ansible/helpers.py b/ansible_mitogen/helpers.py similarity index 99% rename from mitogen/ansible/helpers.py rename to ansible_mitogen/helpers.py index ed44e20a..518c0780 100644 --- a/mitogen/ansible/helpers.py +++ b/ansible_mitogen/helpers.py @@ -38,8 +38,6 @@ import json import subprocess import time -import mitogen - # Prevent accidental import of an Ansible module from hanging on stdin read. import ansible.module_utils.basic ansible.module_utils.basic._ANSIBLE_ARGS = '{}' diff --git a/ansible_mitogen/strategy/__init__.py b/ansible_mitogen/strategy/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/mitogen/ansible/strategy.py b/ansible_mitogen/strategy/mitogen.py similarity index 95% rename from mitogen/ansible/strategy.py rename to ansible_mitogen/strategy/mitogen.py index 97235495..ed1fe78a 100644 --- a/mitogen/ansible/strategy.py +++ b/ansible_mitogen/strategy/mitogen.py @@ -25,12 +25,14 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +from __future__ import absolute_import + import mitogen import mitogen.master import mitogen.service import mitogen.unix import mitogen.utils -import mitogen.ansible.action +import ansible_mitogen.action.mitogen import ansible.errors import ansible.plugins.strategy.linear @@ -71,7 +73,7 @@ class StrategyModule(ansible.plugins.strategy.linear.StrategyModule): real_get = action_loader.get def get(name, *args, **kwargs): if name == 'normal': - return mitogen.ansible.action.ActionModule(*args, **kwargs) + return ansible_mitogen.action.mitogen.ActionModule(*args, **kwargs) return real_get(name, *args, **kwargs) action_loader.get = get diff --git a/mitogen/core.py b/mitogen/core.py index 0c1924e4..1ec2bc57 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -407,7 +407,6 @@ class Importer(object): def __init__(self, router, context, core_src): self._context = context self._present = {'mitogen': [ - 'mitogen.ansible', 'mitogen.compat', 'mitogen.compat.pkgutil', 'mitogen.fakessh', diff --git a/setup.py b/setup.py index 49cbedb5..637d13b2 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ setup( author = 'David Wilson', license = 'New BSD', url = 'https://github.com/dw/mitogen/', - packages = ['mitogen'], + packages = ['mitogen', 'ansible_mitogen'], zip_safe = False, classifiers = [ 'Development Status :: 3 - Alpha',