How to use the acquisition.tomviz.jsonrpc.__init__.JsonRpcError function in Acquisition

To help you get started, we’ve selected a few Acquisition 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 OpenChemistry / tomviz / acquisition / tomviz / jsonrpc / __init__.py View on Github external
error['data'] = self.data

        return error


class ParseError(JsonRpcError):
    def __init__(self, message='Parse error.', data=None):
        super(ParseError, self).__init__(PARSE_ERROR, message, data)


class InvalidRequest(JsonRpcError):
    def __init__(self, message='Invalid request.', data=None):
        super(InvalidRequest, self).__init__(INVALID_REQUEST, message, data)


class MethodNotFound(JsonRpcError):
    def __init__(self, message='Method not found.', data=None):
        super(MethodNotFound, self).__init__(METHOD_NOT_FOUND, message, data)


class InvalidParams(JsonRpcError):
    def __init__(self, message='Invalid parameters.', data=None):
        super(InvalidParams, self).__init__(INVALID_PARAMS, message, data)


class InternalError(JsonRpcError):
    def __init__(self, message='Internal error.', data=None):
        super(InternalError, self).__init__(INTERNAL_ERROR, message, data)


class ServerError(JsonRpcError):
    def __init__(self, message='Server error.', data=None):
github OpenChemistry / tomviz / acquisition / tomviz / jsonrpc / __init__.py View on Github external
self.message = message
        self.data = data

    def to_json(self):
        error = {
            'code': self.code,
            'message': self.message,
        }

        if self.data:
            error['data'] = self.data

        return error


class ParseError(JsonRpcError):
    def __init__(self, message='Parse error.', data=None):
        super(ParseError, self).__init__(PARSE_ERROR, message, data)


class InvalidRequest(JsonRpcError):
    def __init__(self, message='Invalid request.', data=None):
        super(InvalidRequest, self).__init__(INVALID_REQUEST, message, data)


class MethodNotFound(JsonRpcError):
    def __init__(self, message='Method not found.', data=None):
        super(MethodNotFound, self).__init__(METHOD_NOT_FOUND, message, data)


class InvalidParams(JsonRpcError):
    def __init__(self, message='Invalid parameters.', data=None):
github OpenChemistry / tomviz / acquisition / tomviz / jsonrpc / __init__.py View on Github external
try:
                if isinstance(params, list):
                    result = func(*params)
                elif isinstance(params, dict):
                    result = func(**params)
                else:
                    raise InvalidParams()
            except ValueError as vex:
                raise InvalidParams(message=str(vex),
                                    data=json.dumps(traceback.format_exc()))
            except Exception as ex:
                raise ServerError(message=str(ex),
                                  data=json.dumps(traceback.format_exc()))

            return self._response(id, result)
        except JsonRpcError as err:
            return jsonrpc_message({
                'id': id,
                'error': err.to_json()
            })
github OpenChemistry / tomviz / acquisition / tomviz / jsonrpc / __init__.py View on Github external
class ParseError(JsonRpcError):
    def __init__(self, message='Parse error.', data=None):
        super(ParseError, self).__init__(PARSE_ERROR, message, data)


class InvalidRequest(JsonRpcError):
    def __init__(self, message='Invalid request.', data=None):
        super(InvalidRequest, self).__init__(INVALID_REQUEST, message, data)


class MethodNotFound(JsonRpcError):
    def __init__(self, message='Method not found.', data=None):
        super(MethodNotFound, self).__init__(METHOD_NOT_FOUND, message, data)


class InvalidParams(JsonRpcError):
    def __init__(self, message='Invalid parameters.', data=None):
        super(InvalidParams, self).__init__(INVALID_PARAMS, message, data)


class InternalError(JsonRpcError):
    def __init__(self, message='Internal error.', data=None):
        super(InternalError, self).__init__(INTERNAL_ERROR, message, data)


class ServerError(JsonRpcError):
    def __init__(self, message='Server error.', data=None):
        super(ServerError, self).__init__(SERVER_ERROR, message, data)


class JsonRpcHandler(object):
    def __init__(self, path):
github OpenChemistry / tomviz / acquisition / tomviz / jsonrpc / __init__.py View on Github external
'code': self.code,
            'message': self.message,
        }

        if self.data:
            error['data'] = self.data

        return error


class ParseError(JsonRpcError):
    def __init__(self, message='Parse error.', data=None):
        super(ParseError, self).__init__(PARSE_ERROR, message, data)


class InvalidRequest(JsonRpcError):
    def __init__(self, message='Invalid request.', data=None):
        super(InvalidRequest, self).__init__(INVALID_REQUEST, message, data)


class MethodNotFound(JsonRpcError):
    def __init__(self, message='Method not found.', data=None):
        super(MethodNotFound, self).__init__(METHOD_NOT_FOUND, message, data)


class InvalidParams(JsonRpcError):
    def __init__(self, message='Invalid parameters.', data=None):
        super(InvalidParams, self).__init__(INVALID_PARAMS, message, data)


class InternalError(JsonRpcError):
    def __init__(self, message='Internal error.', data=None):
github OpenChemistry / tomviz / acquisition / tomviz / jsonrpc / __init__.py View on Github external
class MethodNotFound(JsonRpcError):
    def __init__(self, message='Method not found.', data=None):
        super(MethodNotFound, self).__init__(METHOD_NOT_FOUND, message, data)


class InvalidParams(JsonRpcError):
    def __init__(self, message='Invalid parameters.', data=None):
        super(InvalidParams, self).__init__(INVALID_PARAMS, message, data)


class InternalError(JsonRpcError):
    def __init__(self, message='Internal error.', data=None):
        super(InternalError, self).__init__(INTERNAL_ERROR, message, data)


class ServerError(JsonRpcError):
    def __init__(self, message='Server error.', data=None):
        super(ServerError, self).__init__(SERVER_ERROR, message, data)


class JsonRpcHandler(object):
    def __init__(self, path):
        self._path = path
        self._methods = {}

    def rpc(self, request):

        jsonrpc = request.get('jsonrpc')
        id = request.get('id')
        method = request.get('method')
        params = request.get('params', {})
github OpenChemistry / tomviz / acquisition / tomviz / jsonrpc / __init__.py View on Github external
class InvalidRequest(JsonRpcError):
    def __init__(self, message='Invalid request.', data=None):
        super(InvalidRequest, self).__init__(INVALID_REQUEST, message, data)


class MethodNotFound(JsonRpcError):
    def __init__(self, message='Method not found.', data=None):
        super(MethodNotFound, self).__init__(METHOD_NOT_FOUND, message, data)


class InvalidParams(JsonRpcError):
    def __init__(self, message='Invalid parameters.', data=None):
        super(InvalidParams, self).__init__(INVALID_PARAMS, message, data)


class InternalError(JsonRpcError):
    def __init__(self, message='Internal error.', data=None):
        super(InternalError, self).__init__(INTERNAL_ERROR, message, data)


class ServerError(JsonRpcError):
    def __init__(self, message='Server error.', data=None):
        super(ServerError, self).__init__(SERVER_ERROR, message, data)


class JsonRpcHandler(object):
    def __init__(self, path):
        self._path = path
        self._methods = {}

    def rpc(self, request):