mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-23 17:16:33 +00:00
Use new format for logging exceptions - utils/apparmor.py (#3190)
This commit is contained in:
parent
aa4f4c8d47
commit
6c679b07e1
@ -21,12 +21,14 @@ def get_profile_name(profile_file):
|
|||||||
continue
|
continue
|
||||||
profiles.add(match.group(1))
|
profiles.add(match.group(1))
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
_LOGGER.error("Can't read AppArmor profile: %s", err)
|
raise AppArmorFileError(
|
||||||
raise AppArmorFileError() from err
|
f"Can't read AppArmor profile: {err}", _LOGGER.error
|
||||||
|
) from err
|
||||||
|
|
||||||
if len(profiles) != 1:
|
if len(profiles) != 1:
|
||||||
_LOGGER.error("To many profiles inside file: %s", profiles)
|
raise AppArmorInvalidError(
|
||||||
raise AppArmorInvalidError()
|
f"To many profiles inside file: {profiles}", _LOGGER.error
|
||||||
|
)
|
||||||
|
|
||||||
return profiles.pop()
|
return profiles.pop()
|
||||||
|
|
||||||
@ -53,13 +55,15 @@ def adjust_profile(profile_name, profile_file, profile_new):
|
|||||||
else:
|
else:
|
||||||
profile_data.append(line.replace(org_profile, profile_name))
|
profile_data.append(line.replace(org_profile, profile_name))
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
_LOGGER.error("Can't adjust origin profile: %s", err)
|
raise AppArmorFileError(
|
||||||
raise AppArmorFileError() from err
|
f"Can't adjust origin profile: {err}", _LOGGER.error
|
||||||
|
) from err
|
||||||
|
|
||||||
# Write into new file
|
# Write into new file
|
||||||
try:
|
try:
|
||||||
with profile_new.open("w") as profile:
|
with profile_new.open("w") as profile:
|
||||||
profile.writelines(profile_data)
|
profile.writelines(profile_data)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
_LOGGER.error("Can't write new profile: %s", err)
|
raise AppArmorFileError(
|
||||||
raise AppArmorFileError() from err
|
f"Can't write new profile: {err}", _LOGGER.error
|
||||||
|
) from err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user