Exemplo n.º 1
0
def handle_command(pymux, cli, input_string):
    """
    Handle command.
    """
    assert isinstance(input_string, six.text_type)

    input_string = input_string.strip()
    logger.info('handle command: %s %s.', input_string, type(input_string))

    if input_string and not input_string.startswith('#'):  # Ignore comments.
        try:
            if sys.version.startswith('2.6.'):
                # In Python2.6, shlex doesn't work with unicode input.
                parts = shlex.split(input_string.encode('utf-8'))
                parts = [p.decode('utf-8') for p in parts]
            else:
                parts = shlex.split(input_string)
        except ValueError as e:
            # E.g. missing closing quote.
            pymux.show_message(cli, 'Invalid command %s: %s' % (input_string, e))
        else:
            call_command_handler(parts[0], pymux, cli, parts[1:])
Exemplo n.º 2
0
def handle_command(pymux, cli, input_string):
    """
    Handle command.
    """
    assert isinstance(input_string, six.text_type)

    input_string = input_string.strip()
    logger.info('handle command: %s %s.', input_string, type(input_string))

    if input_string and not input_string.startswith('#'):  # Ignore comments.
        try:
            if sys.version.startswith('2.6.'):
                # In Python2.6, shlex doesn't work with unicode input.
                parts = shlex.split(input_string.encode('utf-8'))
                parts = [p.decode('utf-8') for p in parts]
            else:
                parts = shlex.split(input_string)
        except ValueError as e:
            # E.g. missing closing quote.
            pymux.show_message(cli,
                               'Invalid command %s: %s' % (input_string, e))
        else:
            call_command_handler(parts[0], pymux, cli, parts[1:])
Exemplo n.º 3
0
 def data_received(self, data):
     logger.info('Got data %r' % data)