return results for new command for commands marked with the deprecated decorator

This commit is contained in:
Jack Robison 2017-08-15 11:31:35 -04:00
parent 667f417060
commit 46c5a98752
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF

View file

@ -87,10 +87,6 @@ class UnknownAPIMethodError(Exception):
pass
class DeprecatedAPIMethodError(Exception):
pass
class NotAllowedDuringStartupError(Exception):
pass
@ -339,12 +335,6 @@ class AuthJSONRPCServer(AuthorizedBase):
request, id_
)
return server.NOT_DONE_YET
except DeprecatedAPIMethodError:
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 = {}
@ -472,14 +462,6 @@ class AuthJSONRPCServer(AuthorizedBase):
else:
return server_port[0], 80
def _check_deprecated(self, function_path):
if function_path in self.deprecated_methods:
new_command = self.deprecated_methods[function_path]._new_command
log.warning('API function \"%s\" is deprecated, please update to use \"%s\"',
function_path, new_command)
raise DeprecatedAPIMethodError(function_path)
def _verify_method_is_callable(self, function_path):
if function_path not in self.callable_methods:
raise UnknownAPIMethodError(function_path)
@ -488,7 +470,11 @@ class AuthJSONRPCServer(AuthorizedBase):
raise NotAllowedDuringStartupError(function_path)
def _get_jsonrpc_method(self, function_path):
self._check_deprecated(function_path)
if function_path in self.deprecated_methods:
new_command = self.deprecated_methods[function_path]._new_command
log.warning('API function \"%s\" is deprecated, please update to use \"%s\"',
function_path, new_command)
function_path = new_command
self._verify_method_is_callable(function_path)
return self.callable_methods.get(function_path)