How to use the acquisition.tomviz.jsonrpc.__init__.ParseError 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
def handle_rpc():
                json_body = {}
                try:
                    if bottle.request.headers['CONTENT_TYPE'] \
                       not in ('application/json', 'application/json-rpc'):
                        raise ParseError(
                            message='Invalid content type.',
                            data=bottle.request.headers['CONTENT_TYPE'])
                    try:
                        json_body = bottle.json_loads(
                            bottle.request.body.read())
                    except ValueError:
                        raise ParseError(
                            message='Invalid JSON.',
                            data=json.dumps(traceback.format_exc()))

                    response = self._endpoint.rpc(json_body)
                    # If we have error set the HTTP status code
                    if 'error' in response:
                        error = response['error']
                        status = jsonrpc_code_to_status.get(error['code'], 500)
                        bottle.response.status = status
github OpenChemistry / tomviz / acquisition / tomviz / jsonrpc / __init__.py View on Github external
def __init__(self, message='Parse error.', data=None):
        super(ParseError, self).__init__(PARSE_ERROR, message, data)