Supporting body both as dict and str
This commit is contained in:
parent
99a93012ce
commit
bdcc6bcf1c
1 changed files with 14 additions and 8 deletions
|
@ -69,15 +69,21 @@ def _init_plugin(plugin, reload=False):
|
||||||
|
|
||||||
|
|
||||||
def _exec_func(body, retry=True):
|
def _exec_func(body, retry=True):
|
||||||
try:
|
args = {}
|
||||||
logging.info('Received push addressed to me: {}'.format(body))
|
logging.info('Received push addressed to me: {}'.format(body))
|
||||||
args = json.loads(body['args']) if 'args' in body else {}
|
|
||||||
if 'plugin' not in body:
|
if 'plugin' not in body:
|
||||||
logging.warn('No plugin specified')
|
logging.warn('No plugin specified')
|
||||||
return
|
return
|
||||||
|
|
||||||
plugin_name = body['plugin']
|
plugin_name = body['plugin']
|
||||||
|
|
||||||
|
if 'args' in body:
|
||||||
|
args = json.loads(body['args']) \
|
||||||
|
if isinstance(body['args'], str) \
|
||||||
|
else body['args']
|
||||||
|
|
||||||
|
try:
|
||||||
try:
|
try:
|
||||||
plugin = _init_plugin(plugin_name)
|
plugin = _init_plugin(plugin_name)
|
||||||
except RuntimeError as e: # Module/class not found
|
except RuntimeError as e: # Module/class not found
|
||||||
|
|
Loading…
Reference in a new issue