diff --git a/runbullet/__init__.py b/runbullet/__init__.py index d5131d1bd..f17a5df31 100644 --- a/runbullet/__init__.py +++ b/runbullet/__init__.py @@ -69,22 +69,23 @@ def _init_plugin(plugin_name, reload=False): return plugin -def _exec_func(body, retry=True): - args = {} +def _exec_func(args, retry=True): + args = json.loads(args) \ + if isinstance(args, str) \ + else args - if 'action' not in body: + if 'action' not in args: logging.warn('No action specified') return - action = body.pop('action') + if 'target' in args: + args.pop('target') + + action = args.pop('action') tokens = action.split('.') module_name = str.join('.', tokens[:-1]) method_name = tokens[-1:][0] - args = json.loads(body) \ - if isinstance(body, str) \ - else body - try: plugin = _init_plugin(module_name) except RuntimeError as e: # Module/class not found @@ -110,11 +111,11 @@ def _exec_func(body, retry=True): logging.exception(e) if retry: # Put the action back where it was before retrying - body['action'] = action + args['action'] = action logging.info('Reloading plugin {} and retrying'.format(module_name)) _init_plugin(module_name, reload=True) - _exec_func(body, retry=False) + _exec_func(args, retry=False) def _on_push(ws, data):