pull/1126/head
Alex Willmer 2 months ago
parent a774b87f3e
commit 403d71fd1b

@ -83,7 +83,6 @@ import multiprocessing
import os import os
import struct import struct
import mitogen.core
import mitogen.parent import mitogen.parent
@ -265,7 +264,7 @@ class LinuxPolicy(FixedPolicy):
for x in range(16): for x in range(16):
chunks.append(struct.pack('<Q', mask & shiftmask)) chunks.append(struct.pack('<Q', mask & shiftmask))
mask >>= 64 mask >>= 64
return mitogen.core.b('').join(chunks) return b''.join(chunks)
def _get_thread_ids(self): def _get_thread_ids(self):
try: try:

@ -32,15 +32,13 @@ __metaclass__ = type
import logging import logging
import os import os
import ansible.utils.display
import mitogen.core import mitogen.core
import mitogen.utils import mitogen.utils
try:
from __main__ import display
except ImportError:
import ansible.utils.display
display = ansible.utils.display.Display()
display = ansible.utils.display.Display()
#: The process name set via :func:`set_process_name`. #: The process name set via :func:`set_process_name`.
_process_name = None _process_name = None

@ -35,18 +35,16 @@ import pwd
import random import random
import traceback import traceback
try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote
from ansible.module_utils._text import to_bytes
from ansible.parsing.utils.jsonify import jsonify
import ansible import ansible
import ansible.constants import ansible.constants
import ansible.plugins import ansible.plugins
import ansible.plugins.action import ansible.plugins.action
import ansible.utils.unsafe_proxy
import ansible.vars.clean
from ansible.module_utils.common.text.converters import to_bytes, to_text
from ansible.module_utils.six.moves import shlex_quote
from ansible.parsing.utils.jsonify import jsonify
import mitogen.core import mitogen.core
import mitogen.select import mitogen.select
@ -57,24 +55,6 @@ import ansible_mitogen.target
import ansible_mitogen.utils import ansible_mitogen.utils
import ansible_mitogen.utils.unsafe import ansible_mitogen.utils.unsafe
from ansible.module_utils._text import to_text
try:
from ansible.utils.unsafe_proxy import wrap_var
except ImportError:
from ansible.vars.unsafe_proxy import wrap_var
try:
# ansible 2.8 moved remove_internal_keys to the clean module
from ansible.vars.clean import remove_internal_keys
except ImportError:
try:
from ansible.vars.manager import remove_internal_keys
except ImportError:
# ansible 2.3.3 has remove_internal_keys as a protected func on the action class
# we'll fallback to calling self._remove_internal_keys in this case
remove_internal_keys = lambda a: "Not found"
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -413,10 +393,7 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase):
self._remove_tmp_path(tmp) self._remove_tmp_path(tmp)
# prevents things like discovered_interpreter_* or ansible_discovered_interpreter_* from being set # prevents things like discovered_interpreter_* or ansible_discovered_interpreter_* from being set
# handle ansible 2.3.3 that has remove_internal_keys in a different place ansible.vars.clean.remove_internal_keys(result)
check = remove_internal_keys(result)
if check == 'Not found':
self._remove_internal_keys(result)
# taken from _execute_module of ansible 2.8.6 # taken from _execute_module of ansible 2.8.6
# propagate interpreter discovery results back to the controller # propagate interpreter discovery results back to the controller
@ -440,7 +417,7 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase):
result['deprecations'] = [] result['deprecations'] = []
result['deprecations'].extend(self._discovery_deprecation_warnings) result['deprecations'].extend(self._discovery_deprecation_warnings)
return wrap_var(result) return ansible.utils.unsafe_proxy.wrap_var(result)
def _postprocess_response(self, result): def _postprocess_response(self, result):
""" """

@ -477,7 +477,7 @@ def read_file(path):
finally: finally:
os.close(fd) os.close(fd)
return mitogen.core.b('').join(bits) return b''.join(bits)
def _propagate_deps(invocation, planner, context): def _propagate_deps(invocation, planner, context):

@ -42,13 +42,7 @@ except ImportError:
import ansible_mitogen.connection import ansible_mitogen.connection
import ansible_mitogen.process import ansible_mitogen.process
viewkeys = getattr(dict, 'viewkeys', dict.keys)
if sys.version_info > (3,):
viewkeys = dict.keys
elif sys.version_info > (2, 7):
viewkeys = dict.viewkeys
else:
viewkeys = lambda dct: set(dct)
def dict_diff(old, new): def dict_diff(old, new):

@ -61,10 +61,9 @@ import mitogen.utils
import ansible import ansible
import ansible.constants as C import ansible.constants as C
import ansible.errors import ansible.errors
import ansible_mitogen.logging import ansible_mitogen.logging
import ansible_mitogen.services import ansible_mitogen.services
from mitogen.core import b
import ansible_mitogen.affinity import ansible_mitogen.affinity
@ -639,7 +638,7 @@ class MuxProcess(object):
try: try:
# Let the parent know our listening socket is ready. # Let the parent know our listening socket is ready.
mitogen.core.io_op(self.model.child_sock.send, b('1')) mitogen.core.io_op(self.model.child_sock.send, b'1')
# Block until the socket is closed, which happens on parent exit. # Block until the socket is closed, which happens on parent exit.
mitogen.core.io_op(self.model.child_sock.recv, 1) mitogen.core.io_op(self.model.child_sock.recv, 1)
finally: finally:

@ -40,7 +40,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import atexit import atexit
import ctypes
import json import json
import io
import logging
import os import os
import re import re
import shlex import shlex
@ -50,19 +53,12 @@ import tempfile
import traceback import traceback
import types import types
from ansible.module_utils.six.moves import iteritems, shlex_quote
import mitogen.core import mitogen.core
import ansible_mitogen.target # TODO: circular import import ansible_mitogen.target # TODO: circular import
from mitogen.core import b
from mitogen.core import bytes_partition
from mitogen.core import str_rpartition
from mitogen.core import to_text from mitogen.core import to_text
try:
import ctypes
except ImportError:
# Python 2.4
ctypes = None
try: try:
# Python >= 3.4, PEP 451 ModuleSpec API # Python >= 3.4, PEP 451 ModuleSpec API
import importlib.machinery import importlib.machinery
@ -71,21 +67,6 @@ except ImportError:
# Python < 3.4, PEP 302 Import Hooks # Python < 3.4, PEP 302 Import Hooks
import imp import imp
try:
# Cannot use cStringIO as it does not support Unicode.
from StringIO import StringIO
except ImportError:
from io import StringIO
try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote
# Absolute imports for <2.5.
logging = __import__('logging')
# Prevent accidental import of an Ansible module from hanging on stdin read. # Prevent accidental import of an Ansible module from hanging on stdin read.
import ansible.module_utils.basic import ansible.module_utils.basic
ansible.module_utils.basic._ANSIBLE_ARGS = '{}' ansible.module_utils.basic._ANSIBLE_ARGS = '{}'
@ -103,7 +84,6 @@ if ctypes:
except AttributeError: except AttributeError:
pass pass
iteritems = getattr(dict, 'iteritems', dict.items)
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -217,13 +197,13 @@ class EnvironmentFileWatcher(object):
for line in fp: for line in fp:
# ' #export foo=some var ' -> ['#export', 'foo=some var '] # ' #export foo=some var ' -> ['#export', 'foo=some var ']
bits = shlex_split_b(line) bits = shlex_split_b(line)
if (not bits) or bits[0].startswith(b('#')): if (not bits) or bits[0].startswith(b'#'):
continue continue
if bits[0] == b('export'): if bits[0] == b'export':
bits.pop(0) bits.pop(0)
key, sep, value = bytes_partition(b(' ').join(bits), b('=')) key, sep, value = b' '.join(bits).partition(b'=')
if key and sep: if key and sep:
yield key, value yield key, value
@ -596,7 +576,7 @@ class ModuleUtilsImporter(object):
mod.__path__ = [] mod.__path__ = []
mod.__package__ = str(fullname) mod.__package__ = str(fullname)
else: else:
mod.__package__ = str(str_rpartition(to_text(fullname), '.')[0]) mod.__package__ = str(to_text(fullname).rpartition('.')[0])
exec(code, mod.__dict__) exec(code, mod.__dict__)
self._loaded.add(fullname) self._loaded.add(fullname)
return mod return mod
@ -647,11 +627,11 @@ class NewStyleStdio(object):
self.original_stdout = sys.stdout self.original_stdout = sys.stdout
self.original_stderr = sys.stderr self.original_stderr = sys.stderr
self.original_stdin = sys.stdin self.original_stdin = sys.stdin
sys.stdout = StringIO() sys.stdout = io.StringIO()
sys.stderr = StringIO() sys.stderr = io.StringIO()
encoded = json.dumps({'ANSIBLE_MODULE_ARGS': args}) encoded = json.dumps({'ANSIBLE_MODULE_ARGS': args})
ansible.module_utils.basic._ANSIBLE_ARGS = utf8(encoded) ansible.module_utils.basic._ANSIBLE_ARGS = utf8(encoded)
sys.stdin = StringIO(mitogen.core.to_text(encoded)) sys.stdin = io.StringIO(mitogen.core.to_text(encoded))
self.original_get_path = getattr(ansible.module_utils.basic, self.original_get_path = getattr(ansible.module_utils.basic,
'get_module_path', None) 'get_module_path', None)
@ -819,7 +799,7 @@ class ScriptRunner(ProgramRunner):
self.interpreter_fragment = interpreter_fragment self.interpreter_fragment = interpreter_fragment
self.is_python = is_python self.is_python = is_python
b_ENCODING_STRING = b('# -*- coding: utf-8 -*-') b_ENCODING_STRING = b'# -*- coding: utf-8 -*-'
def _get_program(self): def _get_program(self):
return self._rewrite_source( return self._rewrite_source(
@ -852,13 +832,13 @@ class ScriptRunner(ProgramRunner):
# While Ansible rewrites the #! using ansible_*_interpreter, it is # While Ansible rewrites the #! using ansible_*_interpreter, it is
# never actually used to execute the script, instead it is a shell # never actually used to execute the script, instead it is a shell
# fragment consumed by shell/__init__.py::build_module_command(). # fragment consumed by shell/__init__.py::build_module_command().
new = [b('#!') + utf8(self.interpreter_fragment)] new = [b'#!' + utf8(self.interpreter_fragment)]
if self.is_python: if self.is_python:
new.append(self.b_ENCODING_STRING) new.append(self.b_ENCODING_STRING)
_, _, rest = bytes_partition(s, b('\n')) _, _, rest = s.partition(b'\n')
new.append(rest) new.append(rest)
return b('\n').join(new) return b'\n'.join(new)
class NewStyleRunner(ScriptRunner): class NewStyleRunner(ScriptRunner):
@ -971,8 +951,7 @@ class NewStyleRunner(ScriptRunner):
# change the default encoding. This hack was removed from Ansible long ago, # change the default encoding. This hack was removed from Ansible long ago,
# but not before permeating into many third party modules. # but not before permeating into many third party modules.
PREHISTORIC_HACK_RE = re.compile( PREHISTORIC_HACK_RE = re.compile(
b(r'reload\s*\(\s*sys\s*\)\s*' rb'reload\s*\(\s*sys\s*\)\s*sys\s*\.\s*setdefaultencoding\([^)]+\)',
r'sys\s*\.\s*setdefaultencoding\([^)]+\)')
) )
def _setup_program(self): def _setup_program(self):
@ -980,7 +959,7 @@ class NewStyleRunner(ScriptRunner):
context=self.service_context, context=self.service_context,
path=self.path, path=self.path,
) )
self.source = self.PREHISTORIC_HACK_RE.sub(b(''), source) self.source = self.PREHISTORIC_HACK_RE.sub(b'', source)
def _get_code(self): def _get_code(self):
try: try:
@ -998,7 +977,7 @@ class NewStyleRunner(ScriptRunner):
if mitogen.core.PY3: if mitogen.core.PY3:
main_module_name = '__main__' main_module_name = '__main__'
else: else:
main_module_name = b('__main__') main_module_name = b'__main__'
def _handle_magic_exception(self, mod, exc): def _handle_magic_exception(self, mod, exc):
""" """
@ -1030,7 +1009,7 @@ class NewStyleRunner(ScriptRunner):
approximation of the original package hierarchy, so that relative approximation of the original package hierarchy, so that relative
imports function correctly. imports function correctly.
""" """
pkg, sep, modname = str_rpartition(self.py_module_name, '.') pkg, sep, _ = self.py_module_name.rpartition('.')
if not sep: if not sep:
return None return None
if mitogen.core.PY3: if mitogen.core.PY3:
@ -1073,7 +1052,7 @@ class NewStyleRunner(ScriptRunner):
class JsonArgsRunner(ScriptRunner): class JsonArgsRunner(ScriptRunner):
JSON_ARGS = b('<<INCLUDE_ANSIBLE_MODULE_JSON_ARGS>>') JSON_ARGS = b'<<INCLUDE_ANSIBLE_MODULE_JSON_ARGS>>'
def _get_args_contents(self): def _get_args_contents(self):
return json.dumps(self.args).encode() return json.dumps(self.args).encode()

@ -39,6 +39,7 @@ __metaclass__ = type
import errno import errno
import grp import grp
import json import json
import logging
import operator import operator
import os import os
import pwd import pwd
@ -51,13 +52,9 @@ import tempfile
import traceback import traceback
import types import types
# Absolute imports for <2.5.
logging = __import__('logging')
import mitogen.core import mitogen.core
import mitogen.parent import mitogen.parent
import mitogen.service import mitogen.service
from mitogen.core import b
try: try:
reduce reduce
@ -65,12 +62,6 @@ except NameError:
# Python 3.x. # Python 3.x.
from functools import reduce from functools import reduce
try:
BaseException
except NameError:
# Python 2.4
BaseException = Exception
# Ansible since PR #41749 inserts "import __main__" into # Ansible since PR #41749 inserts "import __main__" into
# ansible.module_utils.basic. Mitogen's importer will refuse such an import, so # ansible.module_utils.basic. Mitogen's importer will refuse such an import, so
@ -615,8 +606,8 @@ def exec_args(args, in_data='', chdir=None, shell=None, emulate_tty=False):
stdout, stderr = proc.communicate(in_data) stdout, stderr = proc.communicate(in_data)
if emulate_tty: if emulate_tty:
stdout = stdout.replace(b('\n'), b('\r\n')) stdout = stdout.replace(b'\n', b'\r\n')
return proc.returncode, stdout, stderr or b('') return proc.returncode, stdout, stderr or b''
def exec_command(cmd, in_data='', chdir=None, shell=None, emulate_tty=False): def exec_command(cmd, in_data='', chdir=None, shell=None, emulate_tty=False):
@ -746,9 +737,7 @@ def set_file_mode(path, spec, fd=None):
""" """
Update the permissions of a file using the same syntax as chmod(1). Update the permissions of a file using the same syntax as chmod(1).
""" """
if isinstance(spec, int): if isinstance(spec, (int, mitogen.core.long)):
new_mode = spec
elif not mitogen.core.PY3 and isinstance(spec, long):
new_mode = spec new_mode = spec
elif spec.isdigit(): elif spec.isdigit():
new_mode = int(spec, 8) new_mode = int(spec, 8)

@ -65,21 +65,12 @@ import abc
import os import os
import ansible.utils.shlex import ansible.utils.shlex
import ansible.constants as C import ansible.constants as C
import ansible.executor.interpreter_discovery
import ansible.utils.unsafe_proxy
from ansible.module_utils.six import with_metaclass from ansible.module_utils.six import with_metaclass
from ansible.module_utils.parsing.convert_bool import boolean from ansible.module_utils.parsing.convert_bool import boolean
# this was added in Ansible >= 2.8.0; fallback to the default interpreter if necessary
try:
from ansible.executor.interpreter_discovery import discover_interpreter
except ImportError:
discover_interpreter = lambda action,interpreter_name,discovery_mode,task_vars: '/usr/bin/python'
try:
from ansible.utils.unsafe_proxy import AnsibleUnsafeText
except ImportError:
from ansible.vars.unsafe_proxy import AnsibleUnsafeText
import mitogen.core import mitogen.core
@ -115,12 +106,13 @@ def run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_pyth
action._finding_python_interpreter = True action._finding_python_interpreter = True
# fake pipelining so discover_interpreter can be happy # fake pipelining so discover_interpreter can be happy
action._connection.has_pipelining = True action._connection.has_pipelining = True
s = AnsibleUnsafeText(discover_interpreter( s = ansible.executor.interpreter_discovery.discover_interpreter(
action=action, action=action,
interpreter_name=interpreter_name, interpreter_name=interpreter_name,
discovery_mode=s, discovery_mode=s,
task_vars=task_vars)) task_vars=task_vars,
)
s = ansible.utils.unsafe_proxy.UnsafeProxy(s)
# cache discovered interpreter # cache discovered interpreter
task_vars['ansible_facts'][discovered_interpreter_config] = s task_vars['ansible_facts'][discovered_interpreter_config] = s
action._connection.has_pipelining = False action._connection.has_pipelining = False

@ -18,7 +18,6 @@ import mitogen.service
import mitogen.utils import mitogen.utils
def get_file_contents(path): def get_file_contents(path):
""" """
Get the contents of a file. Get the contents of a file.
@ -79,7 +78,6 @@ def md5sum(path):
return hashlib.md5(get_file_contents(path)).hexdigest() return hashlib.md5(get_file_contents(path)).hexdigest()
def work_on_machine(context): def work_on_machine(context):
""" """
Do stuff to a remote context. Do stuff to a remote context.

@ -0,0 +1,4 @@
try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote

@ -102,21 +102,11 @@ try:
except ImportError: except ImportError:
cProfile = None cProfile = None
try:
import thread
except ImportError:
import threading as thread
try: try:
import cPickle as pickle import cPickle as pickle
except ImportError: except ImportError:
import pickle import pickle
try:
from cStringIO import StringIO as BytesIO
except ImportError:
from io import BytesIO
try: try:
BaseException BaseException
except NameError: except NameError:
@ -169,31 +159,32 @@ STUB_CALL_SERVICE = 111
#: :meth:`mitogen.core.Router.add_handler` callbacks to clean up. #: :meth:`mitogen.core.Router.add_handler` callbacks to clean up.
IS_DEAD = 999 IS_DEAD = 999
try:
BaseException
except NameError:
BaseException = Exception
PY24 = sys.version_info < (2, 5) PY24 = sys.version_info < (2, 5)
PY3 = sys.version_info > (3,) PY3 = sys.version_info > (3,)
if PY3: if PY3:
import _thread as thread
from io import BytesIO
b = str.encode b = str.encode
BytesType = bytes BytesType = bytes
UnicodeType = str UnicodeType = str
FsPathTypes = (str,) FsPathTypes = (str,)
BufferType = lambda buf, start: memoryview(buf)[start:] BufferType = lambda buf, start: memoryview(buf)[start:]
iteritems, iterkeys, itervalues = dict.items, dict.keys, dict.values
long = int long = int
else: else:
import thread
from cStringIO import StringIO as BytesIO
b = str b = str
BytesType = str BytesType = str
FsPathTypes = (str, unicode) FsPathTypes = (str, unicode)
BufferType = buffer BufferType = buffer
UnicodeType = unicode UnicodeType = unicode
iteritems, iterkeys, itervalues = dict.iteritems, dict.iterkeys, dict.itervalues
AnyTextType = (BytesType, UnicodeType) AnyTextType = (BytesType, UnicodeType)
try: try:
next next = next
except NameError: except NameError:
next = lambda it: it.next() next = lambda it: it.next()
@ -313,14 +304,14 @@ class Kwargs(dict):
""" """
if PY3: if PY3:
def __init__(self, dct): def __init__(self, dct):
for k, v in dct.items(): for k, v in iteritems(dct):
if type(k) is bytes: if type(k) is bytes:
self[k.decode()] = v self[k.decode()] = v
else: else:
self[k] = v self[k] = v
elif sys.version_info < (2, 6, 5): elif sys.version_info < (2, 6, 5):
def __init__(self, dct): def __init__(self, dct):
for k, v in dct.iteritems(): for k, v in iteritems(dct):
if type(k) is unicode: if type(k) is unicode:
k, _ = encodings.utf_8.encode(k) k, _ = encodings.utf_8.encode(k)
self[k] = v self[k] = v
@ -400,12 +391,19 @@ now = getattr(time, 'monotonic', time.time)
# Python 2.4 # Python 2.4
try: try:
any all, any = all, any
except NameError: except NameError:
def all(it):
for elem in it:
if not elem:
return False
return True
def any(it): def any(it):
for elem in it: for elem in it:
if elem: if elem:
return True return True
return False
def _partition(s, sep, find): def _partition(s, sep, find):

@ -74,9 +74,11 @@ import mitogen.core
import mitogen.minify import mitogen.minify
import mitogen.parent import mitogen.parent
from mitogen.core import any
from mitogen.core import b from mitogen.core import b
from mitogen.core import IOLOG from mitogen.core import IOLOG
from mitogen.core import LOG from mitogen.core import LOG
from mitogen.core import next
from mitogen.core import str_partition from mitogen.core import str_partition
from mitogen.core import str_rpartition from mitogen.core import str_rpartition
from mitogen.core import to_text from mitogen.core import to_text
@ -84,17 +86,6 @@ from mitogen.core import to_text
imap = getattr(itertools, 'imap', map) imap = getattr(itertools, 'imap', map)
izip = getattr(itertools, 'izip', zip) izip = getattr(itertools, 'izip', zip)
try:
any
except NameError:
from mitogen.core import any
try:
next
except NameError:
from mitogen.core import next
RLOG = logging.getLogger('mitogen.ctx') RLOG = logging.getLogger('mitogen.ctx')
@ -1003,6 +994,7 @@ class ModuleFinder(object):
fullname, _, _ = str_rpartition(to_text(fullname), u'.') fullname, _, _ = str_rpartition(to_text(fullname), u'.')
yield fullname yield fullname
def _
def find_related_imports(self, fullname): def find_related_imports(self, fullname):
""" """
Return a list of non-stdlib modules that are directly imported by Return a list of non-stdlib modules that are directly imported by
@ -1064,12 +1056,14 @@ class ModuleFinder(object):
for which source code can be retrieved for which source code can be retrieved
:type fullname: str :type fullname: str
""" """
#LOG.info('find_related(%r)', fullname)
stack = [fullname] stack = [fullname]
found = set() found = set()
while stack: while stack:
name = stack.pop(0) name = stack.pop(0)
names = self.find_related_imports(name) names = self.find_related_imports(name)
#LOG.info('find_related(%r) -> %r -> %r', fullname, name, names)
stack.extend(set(names).difference(set(found).union(stack))) stack.extend(set(names).difference(set(found).union(stack)))
found.update(names) found.update(names)

@ -56,16 +56,13 @@ import zlib
# Absolute imports for <2.5. # Absolute imports for <2.5.
select = __import__('select') select = __import__('select')
try:
import thread
except ImportError:
import threading as thread
import mitogen.core import mitogen.core
from mitogen.core import b from mitogen.core import b
from mitogen.core import bytes_partition from mitogen.core import bytes_partition
from mitogen.core import IOLOG from mitogen.core import IOLOG
from mitogen.core import itervalues
from mitogen.core import next
from mitogen.core import thread
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -79,16 +76,6 @@ try:
except IOError: except IOError:
SELINUX_ENABLED = False SELINUX_ENABLED = False
try:
next
except NameError:
# Python 2.4/2.5
from mitogen.core import next
itervalues = getattr(dict, 'itervalues', dict.values)
if mitogen.core.PY3: if mitogen.core.PY3:
xrange = range xrange = range
closure_attr = '__closure__' closure_attr = '__closure__'

@ -39,18 +39,10 @@ import threading
import mitogen.core import mitogen.core
import mitogen.select import mitogen.select
from mitogen.core import all
from mitogen.core import b from mitogen.core import b
from mitogen.core import str_rpartition from mitogen.core import str_rpartition
try:
all
except NameError:
def all(it):
for elem in it:
if not elem:
return False
return True
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

@ -35,19 +35,10 @@ Construct new children via the OpenSSH client.
import logging import logging
import re import re
try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote
import mitogen.parent import mitogen.parent
from mitogen.compat import shlex_quote
from mitogen.core import b from mitogen.core import b
try:
any
except NameError:
from mitogen.core import any
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

@ -34,11 +34,6 @@ import re
import mitogen.core import mitogen.core
import mitogen.parent import mitogen.parent
try:
any
except NameError:
from mitogen.core import any
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

@ -37,13 +37,7 @@ import sys
import mitogen.core import mitogen.core
import mitogen.master import mitogen.master
from mitogen.core import iteritems
iteritems = getattr(dict, 'iteritems', dict.items)
if mitogen.core.PY3:
iteritems = dict.items
else:
iteritems = dict.iteritems
def setup_gil(): def setup_gil():

@ -11,17 +11,6 @@ import socket
import sys import sys
try:
all
except NameError:
# Python 2.4
def all(it):
for elem in it:
if not elem:
return False
return True
def main(): def main():
module = AnsibleModule(argument_spec={}) module = AnsibleModule(argument_spec={})
module.exit_json( module.exit_json(

@ -1,6 +1,5 @@
import logging import logging
import os import os
import signal
import sys import sys
import tempfile import tempfile
import threading import threading

@ -2,11 +2,7 @@ import unittest
import mitogen.core import mitogen.core
try: from mitogen.core import next
next
except NameError:
def next(it):
return it.next()
class IterSplitTest(unittest.TestCase): class IterSplitTest(unittest.TestCase):

@ -3,10 +3,7 @@ import os
import mitogen.lxc import mitogen.lxc
import mitogen.parent import mitogen.parent
try: from mitogen.core import any
any
except NameError:
from mitogen.core import any
import testlib import testlib

@ -8,13 +8,9 @@ import unittest
import mitogen.core import mitogen.core
import mitogen.parent import mitogen.parent
import testlib from mitogen.core import next
try: import testlib
next
except NameError:
# Python 2.4
from mitogen.core import next
class SockMixin(object): class SockMixin(object):

Loading…
Cancel
Save