2
0
mirror of https://opendev.org/x/pyghmi synced 2026-08-28 01:26:47 +00:00

Fallback behavior on unparseable conditionals

If firmware offers up an unparseable expression, prcoeed as if the
expression were not there in the first place.  The occurance observed
was not viable.  This hampers the improved error message, but the
firmware will still enforce any rules.

Change-Id: I2be9db12b9fa8da9d40bf6829b3cdc02bbdc946d
This commit is contained in:
Jarrod Johnson
2019-03-26 14:58:23 -04:00
parent 7e2a0e258c
commit e47fc0d6a8
+8 -5
View File
@@ -116,11 +116,14 @@ class _ExpEngine(object):
def _eval_conditional(expression, cfg, setting):
if not expression:
return False, ()
parsed = ast.parse(expression)
parsed = parsed.body[0].value
evaluator = _ExpEngine(cfg, setting)
result = evaluator.process(parsed)
return result, evaluator.relatedsettings
try:
parsed = ast.parse(expression)
parsed = parsed.body[0].value
evaluator = _ExpEngine(cfg, setting)
result = evaluator.process(parsed)
return result, evaluator.relatedsettings
except SyntaxError:
return False, ()
class LenovoFirmwareConfig(object):