From bdcc6bcf1c4651ff00326e4d2985f947d478de98 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 3 Nov 2017 16:48:48 +0100 Subject: [PATCH] Supporting body both as dict and str --- runbullet/__init__.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/runbullet/__init__.py b/runbullet/__init__.py index 97d0d78930..7b58a887d2 100644 --- a/runbullet/__init__.py +++ b/runbullet/__init__.py @@ -69,15 +69,21 @@ def _init_plugin(plugin, reload=False): def _exec_func(body, retry=True): + args = {} + logging.info('Received push addressed to me: {}'.format(body)) + + if 'plugin' not in body: + logging.warn('No plugin specified') + return + + plugin_name = body['plugin'] + + if 'args' in body: + args = json.loads(body['args']) \ + if isinstance(body['args'], str) \ + else body['args'] + try: - logging.info('Received push addressed to me: {}'.format(body)) - args = json.loads(body['args']) if 'args' in body else {} - if 'plugin' not in body: - logging.warn('No plugin specified') - return - - plugin_name = body['plugin'] - try: plugin = _init_plugin(plugin_name) except RuntimeError as e: # Module/class not found