fix: Check for name key based on comments on PR

This commit is contained in:
shivanandvp 2022-07-06 20:01:50 -05:00
parent 781ced1a59
commit 27c187084b
No known key found for this signature in database
GPG Key ID: 90465D24C5B3C731

View File

@ -29,7 +29,7 @@ def pretty_name():
def systemctl(units): def systemctl(units):
""" """
For each entry in @p units, run "systemctl <action> <name>", For each entry in @p units, run "systemctl <action> <name>",
where each unit is a map of unit name, action, and a flag. where each unit is a mapping of unit name, action, and a flag.
Returns a failure message, or None if this was successful. Returns a failure message, or None if this was successful.
Units that are not mandatory have their failures suppressed Units that are not mandatory have their failures suppressed
@ -42,6 +42,9 @@ def systemctl(units):
action = "enable" action = "enable"
mandatory = False mandatory = False
else: else:
if not unit.has_key("name"):
libcalamares.utils.error("The key 'name' is missing from the mapping {_unit!s}. Continuing to the next unit.".format(_unit=str(unit)))
continue
name = unit["name"] name = unit["name"]
action = unit.get("action", "enable") action = unit.get("action", "enable")
mandatory = unit.get("mandatory", False) mandatory = unit.get("mandatory", False)