Verified Commit 49b71790 authored by Karel Koci's avatar Karel Koci 🤘

autorun: return None if there was no setting for autorun enable

This should allow caller to possibly handle state when no configuration
is set. No other code should be dirrectly affected because None
evaluates to False in boolean so we are able to still use this function
the same way in conditions. The default value is still False but
representation is None now.
parent a6bf26b5
......@@ -28,7 +28,8 @@ from euci import EUci
def enabled():
"""Returns True if updater can be automatically started by various system
utils. This includes automatic periodic execution, after-boot recovery and
other tools call to configuration aplication.
other tools call to configuration aplication. This returns None if no
configuration was set so it is possible to catch no configuration case.
Relevant uci configuration is: updater.autorun.enable
"""
with EUci() as uci:
......@@ -36,7 +37,9 @@ def enabled():
# TODO use EUci instead of this retype (as this is not perfect)
return uci.get_boolean("updater", "autorun", "enabled")
except UciExceptionNotFound:
return False # No option means disabled
# No option means disabled but instead of False we return None to
# allow to handle no setting situation.
return None
def set_enabled(enabled):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment