reverted autolinted code

pull/658/head
Steven Robertson 4 years ago
parent 99d0b08e2f
commit d64adb15d7

@ -159,7 +159,6 @@ def _connect_ssh(spec):
} }
} }
def _connect_buildah(spec): def _connect_buildah(spec):
""" """
Return ContextService arguments for a Buildah connection. Return ContextService arguments for a Buildah connection.
@ -175,7 +174,6 @@ def _connect_buildah(spec):
} }
} }
def _connect_docker(spec): def _connect_docker(spec):
""" """
Return ContextService arguments for a Docker connection. Return ContextService arguments for a Docker connection.
@ -727,8 +725,8 @@ class Connection(ansible.plugins.connection.ConnectionBase):
) )
stack += (CONNECTION_METHOD[spec.transport()](spec),) stack += (CONNECTION_METHOD[spec.transport()](spec),)
if spec.become() and ((spec.become_user() != spec.remote_user()) if spec.become() and ((spec.become_user() != spec.remote_user()) or
or C.BECOME_ALLOW_SAME_USER): C.BECOME_ALLOW_SAME_USER):
stack += (CONNECTION_METHOD[spec.become_method()](spec),) stack += (CONNECTION_METHOD[spec.become_method()](spec),)
return stack return stack

@ -92,7 +92,6 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase):
that crop up due to this. Mitogen always runs a task completely within that crop up due to this. Mitogen always runs a task completely within
the target user account, so it's not a problem for us. the target user account, so it's not a problem for us.
""" """
def __init__(self, task, connection, *args, **kwargs): def __init__(self, task, connection, *args, **kwargs):
""" """
Verify the received connection is really a Mitogen connection. If not, Verify the received connection is really a Mitogen connection. If not,
@ -186,7 +185,7 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase):
return os.path.join( return os.path.join(
self._connection.get_good_temp_dir(), self._connection.get_good_temp_dir(),
'ansible_mitogen_action_%016x' % ( 'ansible_mitogen_action_%016x' % (
random.getrandbits(8 * 8), random.getrandbits(8*8),
) )
) )

@ -67,7 +67,6 @@ class Invocation(object):
Collect up a module's execution environment then use it to invoke Collect up a module's execution environment then use it to invoke
target.run_module() or helpers.run_module_async() in the target context. target.run_module() or helpers.run_module_async() in the target context.
""" """
def __init__(self, action, connection, module_name, module_args, def __init__(self, action, connection, module_name, module_args,
task_vars, templar, env, wrap_async, timeout_secs): task_vars, templar, env, wrap_async, timeout_secs):
#: ActionBase instance invoking the module. Required to access some #: ActionBase instance invoking the module. Required to access some
@ -113,7 +112,6 @@ class Planner(object):
file, indicates whether or not it understands how to run the module, and file, indicates whether or not it understands how to run the module, and
exports a method to run the module. exports a method to run the module.
""" """
def __init__(self, invocation): def __init__(self, invocation):
self._inv = invocation self._inv = invocation
@ -205,7 +203,6 @@ class ScriptPlanner(BinaryPlanner):
Common functionality for script module planners -- handle interpreter Common functionality for script module planners -- handle interpreter
detection and rewrite. detection and rewrite.
""" """
def _rewrite_interpreter(self, path): def _rewrite_interpreter(self, path):
""" """
Given the original interpreter binary extracted from the script's Given the original interpreter binary extracted from the script's
@ -327,10 +324,10 @@ class NewStylePlanner(ScriptPlanner):
* the module is known to leak like a sieve. * the module is known to leak like a sieve.
""" """
return ( return (
super(NewStylePlanner, self).should_fork() super(NewStylePlanner, self).should_fork() or
or (self._inv.task_vars.get('mitogen_task_isolation') == 'fork') (self._inv.task_vars.get('mitogen_task_isolation') == 'fork') or
or (self._inv.module_name in self.ALWAYS_FORK_MODULES) (self._inv.module_name in self.ALWAYS_FORK_MODULES) or
or (len(self.get_module_map()['custom']) > 0) (len(self.get_module_map()['custom']) > 0)
) )
def get_search_path(self): def get_search_path(self):

@ -116,7 +116,6 @@ def _patch_awx_callback():
EventContext._local = threading.local() EventContext._local = threading.local()
EventContext.add_local = patch_add_local EventContext.add_local = patch_add_local
_patch_awx_callback() _patch_awx_callback()
@ -199,7 +198,6 @@ class AnsibleWrappers(object):
""" """
Manage add/removal of various Ansible runtime hooks. Manage add/removal of various Ansible runtime hooks.
""" """
def _add_plugin_paths(self): def _add_plugin_paths(self):
""" """
Add the Mitogen plug-in directories to the ModuleLoader path, avoiding Add the Mitogen plug-in directories to the ModuleLoader path, avoiding

@ -325,7 +325,6 @@ class PlayContextSpec(Spec):
PlayContext. It is used for normal connections and delegate_to connections, PlayContext. It is used for normal connections and delegate_to connections,
and should always be accurate. and should always be accurate.
""" """
def __init__(self, connection, play_context, transport, inventory_name): def __init__(self, connection, play_context, transport, inventory_name):
self._connection = connection self._connection = connection
self._play_context = play_context self._play_context = play_context
@ -380,9 +379,9 @@ class PlayContextSpec(Spec):
def ansible_ssh_timeout(self): def ansible_ssh_timeout(self):
return ( return (
self._connection.get_task_var('ansible_timeout') self._connection.get_task_var('ansible_timeout') or
or self._connection.get_task_var('ansible_ssh_timeout') self._connection.get_task_var('ansible_ssh_timeout') or
or self.timeout() self.timeout()
) )
def ssh_args(self): def ssh_args(self):
@ -469,8 +468,8 @@ class PlayContextSpec(Spec):
def ansible_doas_exe(self): def ansible_doas_exe(self):
return ( return (
self._connection.get_task_var('ansible_doas_exe') self._connection.get_task_var('ansible_doas_exe') or
or os.environ.get('ANSIBLE_DOAS_EXE') os.environ.get('ANSIBLE_DOAS_EXE')
) )
@ -491,7 +490,6 @@ class MitogenViaSpec(Spec):
having a configruation problem with connection delegation, the answer to having a configruation problem with connection delegation, the answer to
your problem lies in the method implementations below! your problem lies in the method implementations below!
""" """
def __init__(self, inventory_name, host_vars, become_method, become_user, def __init__(self, inventory_name, host_vars, become_method, become_user,
play_context): play_context):
""" """
@ -522,8 +520,8 @@ class MitogenViaSpec(Spec):
def transport(self): def transport(self):
return ( return (
self._host_vars.get('ansible_connection') self._host_vars.get('ansible_connection') or
or C.DEFAULT_TRANSPORT C.DEFAULT_TRANSPORT
) )
def inventory_name(self): def inventory_name(self):
@ -532,16 +530,16 @@ class MitogenViaSpec(Spec):
def remote_addr(self): def remote_addr(self):
# play_context.py::MAGIC_VARIABLE_MAPPING # play_context.py::MAGIC_VARIABLE_MAPPING
return ( return (
self._host_vars.get('ansible_ssh_host') self._host_vars.get('ansible_ssh_host') or
or self._host_vars.get('ansible_host') self._host_vars.get('ansible_host') or
or self._inventory_name self._inventory_name
) )
def remote_user(self): def remote_user(self):
return ( return (
self._host_vars.get('ansible_ssh_user') self._host_vars.get('ansible_ssh_user') or
or self._host_vars.get('ansible_user') self._host_vars.get('ansible_user') or
or C.DEFAULT_REMOTE_USER C.DEFAULT_REMOTE_USER
) )
def become(self): def become(self):
@ -549,9 +547,9 @@ class MitogenViaSpec(Spec):
def become_method(self): def become_method(self):
return ( return (
self._become_method self._become_method or
or self._host_vars.get('ansible_become_method') self._host_vars.get('ansible_become_method') or
or C.DEFAULT_BECOME_METHOD C.DEFAULT_BECOME_METHOD
) )
def become_user(self): def become_user(self):
@ -559,21 +557,21 @@ class MitogenViaSpec(Spec):
def become_pass(self): def become_pass(self):
return optional_secret( return optional_secret(
self._host_vars.get('ansible_become_password') self._host_vars.get('ansible_become_password') or
or self._host_vars.get('ansible_become_pass') self._host_vars.get('ansible_become_pass')
) )
def password(self): def password(self):
return optional_secret( return optional_secret(
self._host_vars.get('ansible_ssh_pass') self._host_vars.get('ansible_ssh_pass') or
or self._host_vars.get('ansible_password') self._host_vars.get('ansible_password')
) )
def port(self): def port(self):
return ( return (
self._host_vars.get('ansible_ssh_port') self._host_vars.get('ansible_ssh_port') or
or self._host_vars.get('ansible_port') self._host_vars.get('ansible_port') or
or C.DEFAULT_REMOTE_PORT C.DEFAULT_REMOTE_PORT
) )
def python_path(self): def python_path(self):
@ -586,15 +584,15 @@ class MitogenViaSpec(Spec):
def private_key_file(self): def private_key_file(self):
# TODO: must come from PlayContext too. # TODO: must come from PlayContext too.
return ( return (
self._host_vars.get('ansible_ssh_private_key_file') self._host_vars.get('ansible_ssh_private_key_file') or
or self._host_vars.get('ansible_private_key_file') self._host_vars.get('ansible_private_key_file') or
or C.DEFAULT_PRIVATE_KEY_FILE C.DEFAULT_PRIVATE_KEY_FILE
) )
def ssh_executable(self): def ssh_executable(self):
return ( return (
self._host_vars.get('ansible_ssh_executable') self._host_vars.get('ansible_ssh_executable') or
or C.ANSIBLE_SSH_EXECUTABLE C.ANSIBLE_SSH_EXECUTABLE
) )
def timeout(self): def timeout(self):
@ -603,9 +601,9 @@ class MitogenViaSpec(Spec):
def ansible_ssh_timeout(self): def ansible_ssh_timeout(self):
return ( return (
self._host_vars.get('ansible_timeout') self._host_vars.get('ansible_timeout') or
or self._host_vars.get('ansible_ssh_timeout') self._host_vars.get('ansible_ssh_timeout') or
or self.timeout() self.timeout()
) )
def ssh_args(self): def ssh_args(self):
@ -613,19 +611,19 @@ class MitogenViaSpec(Spec):
mitogen.core.to_text(term) mitogen.core.to_text(term)
for s in ( for s in (
( (
self._host_vars.get('ansible_ssh_args') self._host_vars.get('ansible_ssh_args') or
or getattr(C, 'ANSIBLE_SSH_ARGS', None) getattr(C, 'ANSIBLE_SSH_ARGS', None) or
or os.environ.get('ANSIBLE_SSH_ARGS') os.environ.get('ANSIBLE_SSH_ARGS')
# TODO: ini entry. older versions. # TODO: ini entry. older versions.
), ),
( (
self._host_vars.get('ansible_ssh_common_args') self._host_vars.get('ansible_ssh_common_args') or
or os.environ.get('ANSIBLE_SSH_COMMON_ARGS') os.environ.get('ANSIBLE_SSH_COMMON_ARGS')
# TODO: ini entry. # TODO: ini entry.
), ),
( (
self._host_vars.get('ansible_ssh_extra_args') self._host_vars.get('ansible_ssh_extra_args') or
or os.environ.get('ANSIBLE_SSH_EXTRA_ARGS') os.environ.get('ANSIBLE_SSH_EXTRA_ARGS')
# TODO: ini entry. # TODO: ini entry.
), ),
) )
@ -635,8 +633,8 @@ class MitogenViaSpec(Spec):
def become_exe(self): def become_exe(self):
return ( return (
self._host_vars.get('ansible_become_exe') self._host_vars.get('ansible_become_exe') or
or C.DEFAULT_BECOME_EXE C.DEFAULT_BECOME_EXE
) )
def sudo_args(self): def sudo_args(self):
@ -696,6 +694,6 @@ class MitogenViaSpec(Spec):
def ansible_doas_exe(self): def ansible_doas_exe(self):
return ( return (
self._host_vars.get('ansible_doas_exe') self._host_vars.get('ansible_doas_exe') or
or os.environ.get('ANSIBLE_DOAS_EXE') os.environ.get('ANSIBLE_DOAS_EXE')
) )

@ -327,7 +327,6 @@ def popen(**kwargs):
is invoked in the child. is invoked in the child.
""" """
real_preexec_fn = kwargs.pop('preexec_fn', None) real_preexec_fn = kwargs.pop('preexec_fn', None)
def preexec_fn(): def preexec_fn():
if _preexec_hook: if _preexec_hook:
_preexec_hook() _preexec_hook()
@ -421,7 +420,7 @@ def _acquire_controlling_tty():
def _linux_broken_devpts_openpty(): def _linux_broken_devpts_openpty():
""" """
# 462: On broken Linux hosts with mismatched configuration (e.g. old #462: On broken Linux hosts with mismatched configuration (e.g. old
/etc/fstab template installed), /dev/pts may be mounted without the gid= /etc/fstab template installed), /dev/pts may be mounted without the gid=
mount option, causing new slave devices to be created with the group ID of mount option, causing new slave devices to be created with the group ID of
the calling process. This upsets glibc, whose openpty() is required by the calling process. This upsets glibc, whose openpty() is required by
@ -452,7 +451,7 @@ def _linux_broken_devpts_openpty():
# TTY. Otherwise when we close the FD we get killed by the kernel, and # TTY. Otherwise when we close the FD we get killed by the kernel, and
# the child we spawn that should really attach to it will get EPERM # the child we spawn that should really attach to it will get EPERM
# during _acquire_controlling_tty(). # during _acquire_controlling_tty().
slave_fd = os.open(pty_name, os.O_RDWR | os.O_NOCTTY) slave_fd = os.open(pty_name, os.O_RDWR|os.O_NOCTTY)
return master_fd, slave_fd return master_fd, slave_fd
except OSError: except OSError:
if master_fd is not None: if master_fd is not None:
@ -640,7 +639,7 @@ class TimerList(object):
def get_timeout(self): def get_timeout(self):
""" """
Return the floating point seconds until the next event is due. Return the floating point seconds until the next event is due.
:returns: :returns:
Floating point delay, or 0.0, or :data:`None` if no events are Floating point delay, or 0.0, or :data:`None` if no events are
scheduled. scheduled.
@ -692,7 +691,6 @@ class PartialZlib(object):
A full compression costs ~6ms on a modern machine, this method costs ~35 A full compression costs ~6ms on a modern machine, this method costs ~35
usec. usec.
""" """
def __init__(self, s): def __init__(self, s):
self.s = s self.s = s
if sys.version_info > (2, 5): if sys.version_info > (2, 5):
@ -842,7 +840,6 @@ class Argv(object):
""" """
Wrapper to defer argv formatting when debug logging is disabled. Wrapper to defer argv formatting when debug logging is disabled.
""" """
def __init__(self, argv): def __init__(self, argv):
self.argv = argv self.argv = argv
@ -869,7 +866,6 @@ class CallSpec(object):
""" """
Wrapper to defer call argument formatting when debug logging is disabled. Wrapper to defer call argument formatting when debug logging is disabled.
""" """
def __init__(self, func, args, kwargs): def __init__(self, func, args, kwargs):
self.func = func self.func = func
self.args = args self.args = args
@ -879,8 +875,8 @@ class CallSpec(object):
bits = [self.func.__module__] bits = [self.func.__module__]
if inspect.ismethod(self.func): if inspect.ismethod(self.func):
im_self = getattr(self.func, IM_SELF_ATTR) im_self = getattr(self.func, IM_SELF_ATTR)
bits.append(getattr(im_self, '__name__', None) bits.append(getattr(im_self, '__name__', None) or
or getattr(type(im_self), '__name__', None)) getattr(type(im_self), '__name__', None))
bits.append(self.func.__name__) bits.append(self.func.__name__)
return u'.'.join(bits) return u'.'.join(bits)
@ -918,13 +914,13 @@ class PollPoller(mitogen.core.Poller):
# TODO: no proof we dont need writemask too # TODO: no proof we dont need writemask too
_readmask = ( _readmask = (
getattr(select, 'POLLIN', 0) getattr(select, 'POLLIN', 0) |
| getattr(select, 'POLLHUP', 0) getattr(select, 'POLLHUP', 0)
) )
def _update(self, fd): def _update(self, fd):
mask = (((fd in self._rfds) and self._readmask) mask = (((fd in self._rfds) and self._readmask) |
| ((fd in self._wfds) and select.POLLOUT)) ((fd in self._wfds) and select.POLLOUT))
if mask: if mask:
self._pollobj.register(fd, mask) self._pollobj.register(fd, mask)
else: else:
@ -1047,8 +1043,8 @@ class EpollPoller(mitogen.core.Poller):
def _control(self, fd): def _control(self, fd):
mitogen.core._vv and IOLOG.debug('%r._control(%r)', self, fd) mitogen.core._vv and IOLOG.debug('%r._control(%r)', self, fd)
mask = (((fd in self._rfds) and select.EPOLLIN) mask = (((fd in self._rfds) and select.EPOLLIN) |
| ((fd in self._wfds) and select.EPOLLOUT)) ((fd in self._wfds) and select.EPOLLOUT))
if mask: if mask:
if fd in self._registered_fds: if fd in self._registered_fds:
self._epoll.modify(fd, mask) self._epoll.modify(fd, mask)
@ -1081,8 +1077,8 @@ class EpollPoller(mitogen.core.Poller):
self._wfds.pop(fd, None) self._wfds.pop(fd, None)
self._control(fd) self._control(fd)
_inmask = (getattr(select, 'EPOLLIN', 0) _inmask = (getattr(select, 'EPOLLIN', 0) |
| getattr(select, 'EPOLLHUP', 0)) getattr(select, 'EPOLLHUP', 0))
def _poll(self, timeout): def _poll(self, timeout):
the_timeout = -1 the_timeout = -1
@ -1253,7 +1249,6 @@ class LogProtocol(LineLoggingProtocolMixin, mitogen.core.DelimitedProtocol):
LogProtocol takes over this FD and creates log messages for anything LogProtocol takes over this FD and creates log messages for anything
written to it. written to it.
""" """
def on_line_received(self, line): def on_line_received(self, line):
""" """
Read a line, decode it as UTF-8, and log it. Read a line, decode it as UTF-8, and log it.
@ -1267,7 +1262,6 @@ class MitogenProtocol(mitogen.core.MitogenProtocol):
Extend core.MitogenProtocol to cause SHUTDOWN to be sent to the child Extend core.MitogenProtocol to cause SHUTDOWN to be sent to the child
during graceful shutdown. during graceful shutdown.
""" """
def on_shutdown(self, broker): def on_shutdown(self, broker):
""" """
Respond to the broker's request for the stream to shut down by sending Respond to the broker's request for the stream to shut down by sending
@ -1430,29 +1424,29 @@ class Connection(object):
# "[1234 refs]" during exit. # "[1234 refs]" during exit.
@staticmethod @staticmethod
def _first_stage(): def _first_stage():
R, W = os.pipe() R,W=os.pipe()
r, w = os.pipe() r,w=os.pipe()
if os.fork(): if os.fork():
os.dup2(0, 100) os.dup2(0,100)
os.dup2(R, 0) os.dup2(R,0)
os.dup2(r, 101) os.dup2(r,101)
os.close(R) os.close(R)
os.close(r) os.close(r)
os.close(W) os.close(W)
os.close(w) os.close(w)
if sys.platform == 'darwin' and sys.executable == '/usr/bin/python': if sys.platform == 'darwin' and sys.executable == '/usr/bin/python':
sys.executable += sys.version[:3] sys.executable += sys.version[:3]
os.environ['ARGV0'] = sys.executable os.environ['ARGV0']=sys.executable
os.execl(sys.executable, sys.executable + '(mitogen:CONTEXT_NAME)') os.execl(sys.executable,sys.executable+'(mitogen:CONTEXT_NAME)')
os.write(1, 'MITO000\n'.encode()) os.write(1,'MITO000\n'.encode())
C = _(os.fdopen(0, 'rb').read(PREAMBLE_COMPRESSED_LEN), 'zip') C=_(os.fdopen(0,'rb').read(PREAMBLE_COMPRESSED_LEN),'zip')
fp = os.fdopen(W, 'wb', 0) fp=os.fdopen(W,'wb',0)
fp.write(C) fp.write(C)
fp.close() fp.close()
fp = os.fdopen(w, 'wb', 0) fp=os.fdopen(w,'wb',0)
fp.write(C) fp.write(C)
fp.close() fp.close()
os.write(1, 'MITO001\n'.encode()) os.write(1,'MITO001\n'.encode())
os.close(2) os.close(2)
def get_python_argv(self): def get_python_argv(self):
@ -1508,7 +1502,7 @@ class Connection(object):
def get_preamble(self): def get_preamble(self):
suffix = ( suffix = (
'\nExternalContext(%r).main()\n' % '\nExternalContext(%r).main()\n' %\
(self.get_econtext_config(),) (self.get_econtext_config(),)
) )
partial = get_core_source_partial() partial = get_core_source_partial()
@ -1615,13 +1609,13 @@ class Connection(object):
if self._reaper: if self._reaper:
return return
# kill: # Avoid killing so child has chance to write cProfile data
self._reaper = Reaper( self._reaper = Reaper(
broker=self._router.broker, broker=self._router.broker,
proc=self.proc, proc=self.proc,
kill=not ( kill=not (
(self.detached and self.child_is_immediate_subprocess) (self.detached and self.child_is_immediate_subprocess) or
or self._router.profiling # kill: # Avoid killing so child has chance to write cProfile data
self._router.profiling
), ),
# Don't delay shutdown waiting for a detached child, since the # Don't delay shutdown waiting for a detached child, since the
# detached child may expect to live indefinitely after its parent # detached child may expect to live indefinitely after its parent
@ -1717,7 +1711,6 @@ class ChildIdAllocator(object):
Allocate new context IDs from a block of unique context IDs allocated by Allocate new context IDs from a block of unique context IDs allocated by
the master process. the master process.
""" """
def __init__(self, router): def __init__(self, router):
self.router = router self.router = router
self.lock = threading.Lock() self.lock = threading.Lock()
@ -1816,7 +1809,6 @@ class CallChain(object):
# chain.reset() automatically invoked. # chain.reset() automatically invoked.
""" """
def __init__(self, context, pipelined=False): def __init__(self, context, pipelined=False):
self.context = context self.context = context
if pipelined: if pipelined:
@ -2004,9 +1996,9 @@ class Context(mitogen.core.Context):
def __eq__(self, other): def __eq__(self, other):
return ( return (
isinstance(other, mitogen.core.Context) isinstance(other, mitogen.core.Context) and
and (other.context_id == self.context_id) (other.context_id == self.context_id) and
and (other.router == self.router) (other.router == self.router)
) )
def __hash__(self): def __hash__(self):
@ -2091,7 +2083,6 @@ class RouteMonitor(object):
:data:`None` in the master process, or reference to the parent context :data:`None` in the master process, or reference to the parent context
we should propagate route updates towards. we should propagate route updates towards.
""" """
def __init__(self, router, parent=None): def __init__(self, router, parent=None):
self.router = router self.router = router
self.parent = parent self.parent = parent
@ -2176,9 +2167,9 @@ class RouteMonitor(object):
""" """
for stream in self.router.get_streams(): for stream in self.router.get_streams():
if target_id in stream.protocol.egress_ids and ( if target_id in stream.protocol.egress_ids and (
(self.parent is None) (self.parent is None) or
or (self.parent.context_id != stream.protocol.remote_id) (self.parent.context_id != stream.protocol.remote_id)
): ):
self._send_one(stream, mitogen.core.DEL_ROUTE, target_id, None) self._send_one(stream, mitogen.core.DEL_ROUTE, target_id, None)
def notice_stream(self, stream): def notice_stream(self, stream):
@ -2348,7 +2339,6 @@ class Router(mitogen.core.Router):
l = mitogen.core.Latch() l = mitogen.core.Latch()
mitogen.core.listen(stream, 'disconnect', l.put) mitogen.core.listen(stream, 'disconnect', l.put)
def disconnect(): def disconnect():
LOG.debug('Starting disconnect of %r', stream) LOG.debug('Starting disconnect of %r', stream)
stream.on_disconnect(self.broker) stream.on_disconnect(self.broker)
@ -2458,7 +2448,7 @@ class Router(mitogen.core.Router):
name=name, name=name,
method_name=method_name, method_name=method_name,
kwargs=mitogen.core.Kwargs(kwargs), kwargs=mitogen.core.Kwargs(kwargs),
) )
if resp['msg'] is not None: if resp['msg'] is not None:
raise mitogen.core.StreamError(resp['msg']) raise mitogen.core.StreamError(resp['msg'])
@ -2679,7 +2669,6 @@ class PopenProcess(Process):
:param subprocess.Popen proc: :param subprocess.Popen proc:
The subprocess. The subprocess.
""" """
def __init__(self, proc, stdin, stdout, stderr=None): def __init__(self, proc, stdin, stdout, stderr=None):
super(PopenProcess, self).__init__(proc.pid, stdin, stdout, stderr) super(PopenProcess, self).__init__(proc.pid, stdin, stdout, stderr)
#: The subprocess. #: The subprocess.
@ -2695,7 +2684,6 @@ class ModuleForwarder(object):
forwarding the request to our parent context, or satisfying the request forwarding the request to our parent context, or satisfying the request
from our local Importer cache. from our local Importer cache.
""" """
def __init__(self, router, parent_context, importer): def __init__(self, router, parent_context, importer):
self.router = router self.router = router
self.parent_context = parent_context self.parent_context = parent_context

@ -241,8 +241,8 @@ class Connection(mitogen.parent.Connection):
because it must interactively accept host keys or type a password. because it must interactively accept host keys or type a password.
""" """
return ( return (
self.options.check_host_keys == 'accept' self.options.check_host_keys == 'accept' or
or self.options.password is not None self.options.password is not None
) )
def create_child(self, **kwargs): def create_child(self, **kwargs):
@ -267,8 +267,8 @@ class Connection(mitogen.parent.Connection):
bits += ['-l', self.options.username] bits += ['-l', self.options.username]
if self.options.port is not None: if self.options.port is not None:
bits += ['-p', str(self.options.port)] bits += ['-p', str(self.options.port)]
if self.options.identities_only and (self.options.identity_file if self.options.identities_only and (self.options.identity_file or
or self.options.password): self.options.password):
bits += ['-o', 'IdentitiesOnly yes'] bits += ['-o', 'IdentitiesOnly yes']
if self.options.identity_file: if self.options.identity_file:
bits += ['-i', self.options.identity_file] bits += ['-i', self.options.identity_file]

@ -114,10 +114,10 @@ SUDO_OPTIONS = [
#(False, 'bool', '--background', '-b') #(False, 'bool', '--background', '-b')
#(False, 'str', '--close-from', '-C') #(False, 'str', '--close-from', '-C')
#(False, 'str', '--login-class', 'c') #(False, 'str', '--login-class', 'c')
(True, 'bool', '--preserve-env', '-E'), (True, 'bool', '--preserve-env', '-E'),
#(False, 'bool', '--edit', '-e') #(False, 'bool', '--edit', '-e')
#(False, 'str', '--group', '-g') #(False, 'str', '--group', '-g')
(True, 'bool', '--set-home', '-H'), (True, 'bool', '--set-home', '-H'),
#(False, 'str', '--host', '-h') #(False, 'str', '--host', '-h')
(False, 'bool', '--login', '-i'), (False, 'bool', '--login', '-i'),
#(False, 'bool', '--remove-timestamp', '-K') #(False, 'bool', '--remove-timestamp', '-K')
@ -146,10 +146,8 @@ SUDO_OPTIONS = [
class OptionParser(optparse.OptionParser): class OptionParser(optparse.OptionParser):
def help(self): def help(self):
self.exit() self.exit()
def error(self, msg): def error(self, msg):
self.exit(msg=msg) self.exit(msg=msg)
def exit(self, status=0, msg=None): def exit(self, status=0, msg=None):
msg = 'sudo: ' + (msg or 'unsupported option') msg = 'sudo: ' + (msg or 'unsupported option')
raise mitogen.core.StreamError(msg) raise mitogen.core.StreamError(msg)
@ -169,7 +167,7 @@ def parse_sudo_flags(args):
parser = make_sudo_parser() parser = make_sudo_parser()
opts, args = parser.parse_args(args) opts, args = parser.parse_args(args)
if len(args): if len(args):
raise mitogen.core.StreamError('unsupported sudo arguments:' + str(args)) raise mitogen.core.StreamError('unsupported sudo arguments:'+str(args))
return opts return opts

Loading…
Cancel
Save