Call a RPC method.

        return object: a result
860
def rpc_call(self, request, method=None, params=None, **kwargs):
        
        args = []
        kwargs = dict()
        if isinstance(params, dict):
            kwargs.update(params)
        else:
            args = list(as_tuple(params))

        method_key = "{0}.{1}".format(self.scheme_name, method)
        if method_key not in self.methods:
            raise AssertionError("Unknown method: {0}".format(method))
        method = self.methods[method_key]

        if hasattr(method, 'request'):
            args.insert(0, request)

        return method(*args, **kwargs)
246560
def RPC(self, url, opname, obj, replytype=None, **kw):
        '''
        '''
        self.Send(url, opname, obj, **kw)
        return self.Receive(replytype, **kw)
106643
def call(self, command, *args):
        

        if not command:
            return

        # Look for local methods first
        try:
            res = self.registered[command]['function'](self, *args)
            return Response('local', res, None)

        # Method not found, try remote
        except KeyError:

            # Execute remote command
            res, err = self.client.call(command, *args)
            return Response('remote', res, err, self.client.is_multi())

        # Local exception
        except Exception as e:
            return Response('local', res, str(e))
1171069
def __call(self, uri, params=None, method="get"):
        
        try:
            resp = self.__get_response(uri, params, method, False)
            rjson = resp.json(**self.json_options)
            assert resp.ok
        except AssertionError:
            msg = "OCode-{}: {}".format(resp.status_code, rjson["message"])
            raise BadRequest(msg)
        except Exception as e:
            msg = "Bad response: {}".format(e)
            log.error(msg, exc_info=True)
            raise BadRequest(msg)
        else:
            return rjson
1100648
def rpc(self, request, args):
        
        if request.method != 'POST':
            return self.error(405, request)
        payload = request.get_data(as_text=True) or '{}'
        request_method = request.args.get('method')
        if not request_method:
            return self.error(
                400, request,
                message="A query string parameter method= is missing."
            )
        name_map = self.service.__nirum_method_names__
        try:
            method_facial_name = name_map.behind_names[request_method]
        except KeyError:
            return self.error(
                400,
                request,
                message="Service doesn't have procedure named '{}'.".format(
                    request_method
                )
            )
        try:
            service_method = getattr(self.service, method_facial_name)
        except AttributeError:
            return self.error(
                400,
                request,
                message="Service has no procedure '{}'.".format(
                    request_method
                )
            )
        if not callable(service_method):
            return self.error(
                400, request,
                message="Remote procedure '{}' is not callable.".format(
                    request_method
                )
            )
        try:
            request_json = json.loads(payload)
        except ValueError:
            return self.error(
                400,
                request,
                message="Invalid JSON payload: '{}'.".format(payload)
            )
        type_hints = self.service.__nirum_service_methods__[method_facial_name]
        try:
            arguments = self._parse_procedure_arguments(
                type_hints,
                request_json
            )
        except (NirumProcedureArgumentValueError,
                NirumProcedureArgumentRequiredError) as e:
            return self.error(400, request, message=str(e))
        method_error_types = self.service.__nirum_method_error_types__
        if not callable(method_error_types):  # generated by older compiler
            method_error_types = method_error_types.get
        method_error = method_error_types(method_facial_name, ())
        try:
            result = service_method(**arguments)
        except method_error as e:
            return self._raw_response(400, serialize_meta(e))
        return_type = type_hints['_return']
        if type_hints.get('_v', 1) >= 2:
            return_type = return_type()
        if not self._check_return_type(return_type, result):
            return self.error(
                400,
                request,
                message="Incorrect return type '{0}' "
                        "for '{1}'. expected '{2}'.".format(
                            typing._type_repr(result.__class__),
                            request_method,
                            typing._type_repr(return_type)
                        )
            )
        else:
            return self._raw_response(200, serialize_meta(result))
708397
def rpc(self, cmd, **kwargs):
        """"""

        func = getattr(self.client, cmd)
        try:
            if self.credentials is None:
                return func(kwargs)
            else:
                return func(self.credentials, kwargs)
        except socket.error as e:
            raise BackendConnectionError(e)
        except (xmlrpclib.ProtocolError, BadStatusLine) as e:
            log.error(e)
            raise BackendError("Error reaching backend.")
943485
function methodCall(method, args, callback) {
      this.debug('methodCall', method);
      var self = this;

      /**
       * Handle RPC Method Callback.
       *
       * @param {Error} error
       * @param {string} response
       * @returns {*}
       */
      function callbackWrapper(error, response) {
        self.debug('methodCall->callbackWrapper', error, response);
        // TODO: error should be customized to handle more error types
        if (error /*&& error.code === "ENOTFOUND" && error.syscall === "getaddrinfo"*/) {
          error.message = "Unable to connect to WordPress.";
          return callback.call(self, error);
        }

        // Parse Response.
        if (_.isString(response) && self.common.is_numeric(response)) {
          response = parseInt(response);
        }
        callback.call(self, error, response);
      }

      this.__client.rpc.methodCall(
        method,
        args || [],
        callbackWrapper
      );

      // @chainable
      return this;
    }
918130
def rpc(rpc_method, attrs={}, req_opts=nil)
      body = Encoding.encode_json(attrs)

      resp = self.class.make_http_request(@conn, @service_full_name, rpc_method, Encoding::JSON, req_opts, body)
      if resp.status != 200
        return ClientResp.new(nil, self.class.error_from_response(resp))
      end

      data = Encoding.decode_json(resp.body)
      return ClientResp.new(data, nil)
    end
545199
def call(*, **, &block)
      pid = fork_and_return_pid(&block)
      write.close
      result = read.read
      Process.wait(pid)

      # rubocop:disable MarshalLoad
      Marshal.load(result)
      # rubocop:enable MarshalLoad
    end
98008
def __system_multiCall(calls, **kwargs):
    
    if not isinstance(calls, list):
        raise RPCInvalidParams('system.multicall first argument should be a list, {} given.'.format(type(calls)))

    handler = kwargs.get(HANDLER_KEY)

    results = []

    for call in calls:
        try:
            result = handler.execute_procedure(call['methodName'], args=call.get('params'))

            # From https://mirrors.talideon.com/articles/multicall.html:
            # "Notice that regular return values are always nested inside a one-element array. This allows you to
            # return structs from functions without confusing them with faults."
            results.append([result])

        except RPCException as e:
            results.append({
                'faultCode': e.code,
                'faultString': e.message,
            })
        except Exception as e:
            results.append({
                'faultCode': RPC_INTERNAL_ERROR,
                'faultString': str(e),
            })

    return results
445852
def invoke(self, results):
        
        args = [results.get(d) for d in self.deps]
        return self.component(*args)
114400
function(rpc_method, fn) {
        rpc.on(rpc_method, _.partial(moduleEventWrap, rpc_method, fn));
    }
318298
def _call_rpc(self, header):
        

        length, _, cmd, feature, address = struct.unpack("<BBBBB", bytes(header))
        rpc_id = (feature << 8) | cmd

        payload = self.rpc_payload[:length]

        status = (1 << 6)
        try:
            response = self.device.call_rpc(address, rpc_id, bytes(payload))
            if len(response) > 0:
                status |= (1 << 7)
        except (RPCInvalidIDError, RPCNotFoundError):
            status = 2  # FIXME: Insert the correct ID here
            response = b''
        except TileNotFoundError:
            status = 0xFF
            response = b''
        except Exception:
            status = 3
            response = b''
            self._logger.exception("Exception raise while calling rpc, header=%s, payload=%s", header, payload)

        self._audit(
            "RPCReceived",
            rpc_id=rpc_id,
            address=address,
            payload=binascii.hexlify(payload),
            status=status,
            response=binascii.hexlify(response)
        )

        resp_header = struct.pack("<BBBB", status, 0, 0, len(response))

        if len(response) > 0:
            self._send_rpc_response(
                (ReceiveHeaderChar.value_handle, resp_header),
                (ReceivePayloadChar.value_handle, response)
            )
        else:
            self._send_rpc_response((ReceiveHeaderChar.value_handle, resp_header))
1272164
def call(*args, &block)
      self.result = defined?(super) ? super(*args, &block) : to_proc.call(*args, &block)
    end
742326
async def _handle_rpc_result(self, message):
        
        rpc_result = message.obj
        state = self._pending_state.pop(rpc_result.req_msg_id, None)
        self._log.debug('Handling RPC result for message %d',
                      rpc_result.req_msg_id)

        if not state:
            # TODO We should not get responses to things we never sent
            # However receiving a File() with empty bytes is "common".
            # See #658, #759 and #958. They seem to happen in a container
            # which contain the real response right after.
            try:
                with BinaryReader(rpc_result.body) as reader:
                    if not isinstance(reader.tgread_object(), upload.File):
                        raise ValueError('Not an upload.File')
            except (TypeNotFoundError, ValueError):
                self._log.info('Received response without parent request: {}'
                               .format(rpc_result.body))
            return

        if rpc_result.error:
            error = rpc_message_to_error(rpc_result.error, state.request)
            self._send_queue.append(
                RequestState(MsgsAck([state.msg_id]), loop=self._loop))

            if not state.future.cancelled():
                state.future.set_exception(error)
        else:
            with BinaryReader(rpc_result.body) as reader:
                result = state.request.read_result(reader)

            if not state.future.cancelled():
                state.future.set_result(result)
713235
def rpc(ctx, call, arguments, api):
    
    try:
        data = list(eval(d) for d in arguments)
    except:
        data = arguments
    ret = getattr(ctx.bitshares.rpc, call)(*data, api=api)
    print_dict(ret)
325810
def _create_result(self, cls):
        # type:(Callable)->Tuple[Any, Callable]
        
        task = instantiate(cls)
        logging.getLogger(__name__).debug("Task object {0} created [{1}].".format(cls.__name__, task))
        return task, get_callable(task)