How to use the acquisition.tomviz.jsonrpc.__init__.InvalidParams 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
if jsonrpc != JSONRPC_VERSION or id is None or method is None:
                raise InvalidRequest()

            if method not in self._methods:
                msg = 'Method "%s" not found.' % method
                raise MethodNotFound(message=msg, data=method)

            func = self._methods[method]

            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
def __init__(self, message='Invalid parameters.', data=None):
        super(InvalidParams, self).__init__(INVALID_PARAMS, message, data)
github OpenChemistry / tomviz / acquisition / tomviz / jsonrpc / __init__.py View on Github external
if method not in self._methods:
                msg = 'Method "%s" not found.' % method
                raise MethodNotFound(message=msg, data=method)

            func = self._methods[method]

            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()
            })