Exemplo n.º 1
0
Arquivo: proby.py Projeto: bmaca/proby
def parse_command(line):
    """
    Determine the command and dispatch the proper handler function.
    """
    tokens = line.split()
    cmd, args = tokens[0], tokens[1:]
    try:
        log.info("%s: %s", cmd, args)
        return COMMANDS.get(cmd, default_cmd)(args)
    except Exception as e:
        log.error("%s: %s", cmd, e)
        return 'error'
Exemplo n.º 2
0
def parse_command(line):
    """
    Determine the command and dispatch the proper handler function.
    """
    tokens = line.split()
    cmd, args = tokens[0].decode('utf-8'), tokens[1:]
    try:
        log.info("%s: %s", cmd, args)
        result = COMMANDS.get(cmd, default_cmd)(args)
        if isinstance(result, bytes):
            return result.decode('utf-8')
        else:
            return result
    except Exception as e:
        log.error("%s: %s", cmd, e)
        return 'error'