forked from platypush/platypush
Don't fail silently if there were errors in parsing ${} variables or getting the context
This commit is contained in:
parent
b4258faa29
commit
9e00428568
2 changed files with 13 additions and 6 deletions
|
@ -130,8 +130,10 @@ class Request(Message):
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
try:
|
try:
|
||||||
exec('{}="{}"'.format(k, re.sub(r'(^|[^\\])"', '\1\\"', v)))
|
exec('{}="{}"'.format(k, re.sub(r'(^|[^\\])"', '\1\\"', v)))
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
logger.warning('Could not set context variable {}={}'.format(k, v))
|
||||||
|
logger.warning('Context: {}'.format(json.dumps(context)))
|
||||||
|
logger.exception(e)
|
||||||
|
|
||||||
parsed_value = ''
|
parsed_value = ''
|
||||||
if not isinstance(_value, str):
|
if not isinstance(_value, str):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import enum
|
import enum
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
@ -340,8 +341,10 @@ class WhileProcedure(LoopProcedure):
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
try:
|
try:
|
||||||
context[k] = eval('"{}"'.format(re.sub(r'(^|[^\\])"', '\1\\"', v)))
|
context[k] = eval('"{}"'.format(re.sub(r'(^|[^\\])"', '\1\\"', v)))
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
logger.warning('Could not parse value for context variable {}={}'.format(k, v))
|
||||||
|
logger.warning('Context: {}'.format(json.dumps(context)))
|
||||||
|
logger.exception(e)
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -453,8 +456,10 @@ class IfProcedure(Procedure):
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
try:
|
try:
|
||||||
exec('{}="{}"'.format(k, re.sub(r'(^|[^\\])"', '\1\\"', v)))
|
exec('{}="{}"'.format(k, re.sub(r'(^|[^\\])"', '\1\\"', v)))
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
logger.warning('Could not set context variable {}={}'.format(k, v))
|
||||||
|
logger.warning('Context: {}'.format(json.dumps(context)))
|
||||||
|
logger.exception(e)
|
||||||
|
|
||||||
condition_true = eval(self.condition)
|
condition_true = eval(self.condition)
|
||||||
response = Response()
|
response = Response()
|
||||||
|
|
Loading…
Reference in a new issue