How to use the jsonrpcserver.__init__.InvalidRequestError function in jsonrpcserver

To help you get started, we’ve selected a few jsonrpcserver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marcinn / json-rpc-server / jsonrpcserver / __init__.py View on Github external
def dispatch(self, request, http_request=None):
        ident = request.get('id')

        log.debug('Dispatching request ID: %s', ident)
        try:
            version = request['jsonrpc']
        except KeyError:
            log.debug('Missing `jsonrpc` key in request payload')
            if ident:
                return InvalidRequestError(
                    ident, 'Missing `jsonrpc` key in request object')
            else:
                return

        if not version == '2.0':
            log.debug('Requested unsupported JSON-RPC version: %s', version)
            if ident:
                return InvalidRequestError(
                    ident, 'Server supports only version 2.0 of '
                           'the JSON-RPC protocol')
            else:
                return

        try:
            method = request['method']
        except KeyError:
github marcinn / json-rpc-server / jsonrpcserver / __init__.py View on Github external
log.debug('Dispatching request ID: %s', ident)
        try:
            version = request['jsonrpc']
        except KeyError:
            log.debug('Missing `jsonrpc` key in request payload')
            if ident:
                return InvalidRequestError(
                    ident, 'Missing `jsonrpc` key in request object')
            else:
                return

        if not version == '2.0':
            log.debug('Requested unsupported JSON-RPC version: %s', version)
            if ident:
                return InvalidRequestError(
                    ident, 'Server supports only version 2.0 of '
                           'the JSON-RPC protocol')
            else:
                return

        try:
            method = request['method']
        except KeyError:
            log.debug('Missing `method` key in request payload')
            if ident:
                return InvalidRequestError(
                    ident, 'Missing `method` key in request object')
            else:
                return

        try:
github marcinn / json-rpc-server / jsonrpcserver / __init__.py View on Github external
if not version == '2.0':
            log.debug('Requested unsupported JSON-RPC version: %s', version)
            if ident:
                return InvalidRequestError(
                    ident, 'Server supports only version 2.0 of '
                           'the JSON-RPC protocol')
            else:
                return

        try:
            method = request['method']
        except KeyError:
            log.debug('Missing `method` key in request payload')
            if ident:
                return InvalidRequestError(
                    ident, 'Missing `method` key in request object')
            else:
                return

        try:
            log.debug('Calling method `%s`', method)
            method = self._methods[method]
        except KeyError:
            log.debug('Method not found: `%s`', method)
            if ident:
                return MethodNotFoundError(ident, method)
            else:
                return

        args = []
        kwargs = {}
github marcinn / json-rpc-server / jsonrpcserver / __init__.py View on Github external
def __init__(self, id, message, data=None):
        super(InvalidRequestError, self).__init__(
            id, message, -32600, data=data)