Skip to content

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
samson0v committed Oct 29, 2024
1 parent db53e7c commit 42f00d5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion thingsboard_gateway/gateway/tb_gateway_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1563,15 +1563,17 @@ def __rpc_gateway_processing(self, request_id, content):
log.info("Received RPC request to the gateway, id: %s, method: %s", str(request_id), content["method"])
arguments = content.get('params', {})
method_to_call = content["method"].replace("gateway_", "")
result = None

if self.__remote_shell is not None:
method_function = self.__remote_shell.shell_commands.get(method_to_call,
self.__gateway_rpc_methods.get(method_to_call))
else:
log.info("Remote shell is disabled.")
method_function = self.__gateway_rpc_methods.get(method_to_call)

if method_function is None and method_to_call in self.__rpc_scheduled_methods_functions:
seconds_to_restart = arguments * 1000 if arguments and arguments != '{}' else 1000
seconds_to_restart = max(seconds_to_restart, 1000)
self.__scheduled_rpc_calls.append([time() * 1000 + seconds_to_restart,
self.__rpc_scheduled_methods_functions[method_to_call]])
log.info("Gateway %s scheduled in %i seconds", method_to_call, seconds_to_restart / 1000)
Expand All @@ -1585,6 +1587,7 @@ def __rpc_gateway_processing(self, request_id, content):
result = method_function(arguments)
else:
result = method_function()

return result

@staticmethod
Expand Down

0 comments on commit 42f00d5

Please sign in to comment.