From 363db1073e75bea386f0e5a16fa84553ced04aa5 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 2 Jun 2017 14:35:51 -0400 Subject: [PATCH] return error for deprecated functions --- lbrynet/lbrynet_daemon/auth/server.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lbrynet/lbrynet_daemon/auth/server.py b/lbrynet/lbrynet_daemon/auth/server.py index 3d5751035..9fa1b92be 100644 --- a/lbrynet/lbrynet_daemon/auth/server.py +++ b/lbrynet/lbrynet_daemon/auth/server.py @@ -87,6 +87,10 @@ class UnknownAPIMethodError(Exception): pass +class DeprecatedAPIMethodError(Exception): + pass + + class NotAllowedDuringStartupError(Exception): pass @@ -335,6 +339,13 @@ class AuthJSONRPCServer(AuthorizedBase): request, id_ ) return server.NOT_DONE_YET + except DeprecatedAPIMethodError: + log.warning('API function is deprecated %s', function_name) + self._render_error( + JSONRPCError(None, JSONRPCError.CODE_METHOD_NOT_FOUND), + request, id_ + ) + return server.NOT_DONE_YET if args == EMPTY_PARAMS or args == []: args_dict = {} @@ -464,13 +475,7 @@ class AuthJSONRPCServer(AuthorizedBase): def _check_deprecated(self, function_path): if function_path in self.deprecated_methods: - deprecated_fn = self.deprecated_methods[function_path] - deprecated_function_path = function_path - new_function_path = deprecated_fn._new_command - log.warning("\"%s\" is deprecated, please update to use \"%s\"", - deprecated_function_path, new_function_path) - return new_function_path - return function_path + raise DeprecatedAPIMethodError(function_path) def _verify_method_is_callable(self, function_path): if function_path not in self.callable_methods: @@ -480,7 +485,7 @@ class AuthJSONRPCServer(AuthorizedBase): raise NotAllowedDuringStartupError(function_path) def _get_jsonrpc_method(self, function_path): - function_path = self._check_deprecated(function_path) + self._check_deprecated(function_path) self._verify_method_is_callable(function_path) return self.callable_methods.get(function_path)