def unpack_rpc_response(status, response=None, rpc_id=0, address=0):
    """Unpack an RPC status back in to payload or exception."""

    status_code = status & ((1 << 6) - 1)

    if address == 8:
        status_code &= ~(1 << 7)

    if status == 0:
        raise BusyRPCResponse()
    elif status == 2:
        raise RPCNotFoundError("rpc %d:%04X not found" % (address, rpc_id))
    elif status == 3:
        raise RPCErrorCode(status_code)
    elif status == 0xFF:
        raise TileNotFoundError("tile %d not found" % address)
    elif status_code != 0:
        raise RPCErrorCode(status_code)

    if response is None:
        response = b''

    return response
def unpack_rpc_response ( status , response = None , rpc_id = 0 , address = 0 ) : status_code = status & ( ( 1 << 6 ) - 1 ) if address == 8 : status_code &= ~ ( 1 << 7 ) if status == 0 : raise BusyRPCResponse ( ) elif status == 2 : raise RPCNotFoundError ( "rpc %d:%04X not found" % ( address , rpc_id ) ) elif status == 3 : raise RPCErrorCode ( status_code ) elif status == 0xFF : raise TileNotFoundError ( "tile %d not found" % address ) elif status_code != 0 : raise RPCErrorCode ( status_code ) if response is None : response = b'' return response
Unpack an RPC status back in to payload or exception.