def parse_command(data, response=True):
    data_len = len(data)

    if data_len < 4:
        return None, None, 0

    if response:
        expected_magic = "\x00RES"
    else:
        expected_magic = "\x00REQ"

    magic = data[:4]
    if magic == expected_magic:
        if data_len >= 12:
            magic, typ, cmd_len = struct.unpack("!4sLL", data[0:12])
            if data_len < 12 + cmd_len:
                return None, None, 0
        else:
            return None, None, 0
    elif txt_command_re.match(data):
        if '\n' in data:
            cmd, data = data.split('\n', 1)
            return cmd.strip(), data, len(cmd)+1
        return None, None, 0
    else:
        raise ProtocolError("Malformed Magic")


    msg_spec = COMMANDS.get(typ, None)
    if not msg_spec:
        raise ProtocolError("Unknown message received: %d" % typ)

    nargs = len(msg_spec[1])
    data = (nargs > 0) and data[12:12 + cmd_len].split('\x00', nargs-1) or []
    if len(data) != nargs:
        raise ProtocolError("Received wrong number of arguments to %s" % msg_spec[0])

    kwargs = dict(
        ((msg_spec[1][i], data[i]) for i in range(nargs))
    )

    return msg_spec[0], kwargs, 12 + cmd_len
Runs an ExecutionRequest for the given product and subjects, and returns the result value.
dataset/ETHPy150Open samuel/python-gearman/gearman/protocol.py/parse_command--crossover with--dataset/ETHPy150Open pantsbuild/pants/tests/python/pants_test/engine/exp/scheduler_test_base.py/SchedulerTestBase.execute