Tidy up logging of command lines for easier cutpaste.

pull/35/head
David Wilson 8 years ago
parent bd2c613b9c
commit 21fb601872

@ -4,6 +4,7 @@ starting new contexts via SSH. Its size is also restricted, since it must be
sent to any context that will be used to establish additional child contexts. sent to any context that will be used to establish additional child contexts.
""" """
import commands
import errno import errno
import getpass import getpass
import imp import imp
@ -55,6 +56,15 @@ def get_child_modules(path, fullname):
return ['%s.%s' % (fullname, name) for _, name, _ in it] return ['%s.%s' % (fullname, name) for _, name, _ in it]
def format_cmdline(args):
return ' '.join(
commands.mkarg(arg).strip()
if any(s in arg for s in (" '\"$")) else
arg
for arg in args
)
def create_child(*args): def create_child(*args):
"""Create a child process whose stdin/stdout is connected to a socket, """Create a child process whose stdin/stdout is connected to a socket,
returning `(pid, socket_obj)`.""" returning `(pid, socket_obj)`."""
@ -69,8 +79,8 @@ def create_child(*args):
raise SystemExit raise SystemExit
childfp.close() childfp.close()
LOG.debug('create_child() child %d fd %d, parent %d, args %r', LOG.debug('create_child() child %d fd %d, parent %d, cmd: %s',
pid, parentfp.fileno(), os.getpid(), args) pid, parentfp.fileno(), os.getpid(), format_cmdline(args))
return pid, os.dup(parentfp.fileno()) return pid, os.dup(parentfp.fileno())
@ -141,8 +151,8 @@ def tty_create_child(*args):
raise SystemExit raise SystemExit
os.close(slave_fd) os.close(slave_fd)
LOG.debug('tty_create_child() child %d fd %d, parent %d, args %r', LOG.debug('tty_create_child() child %d fd %d, parent %d, cmd: %s',
pid, master_fd, os.getpid(), args) pid, master_fd, os.getpid(), format_cmdline(args))
return pid, master_fd return pid, master_fd

@ -62,7 +62,7 @@ class Stream(mitogen.master.Stream):
] ]
bits.append(self.hostname) bits.append(self.hostname)
base = super(Stream, self).get_boot_command() base = super(Stream, self).get_boot_command()
return bits + map(commands.mkarg, base) return bits + [commands.mkarg(s).strip() for s in base]
def connect(self): def connect(self):
super(Stream, self).connect() super(Stream, self).connect()

Loading…
Cancel
Save