mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-14 04:38:20 +10:00
global_settings.py: add error handling for /Users/Shared write
This commit is contained in:
@@ -21,15 +21,17 @@ class global_settings:
|
||||
plistlib.dump({"Developed by Dortania": True,}, Path(self.global_settings_plist).open("wb"))
|
||||
|
||||
def read_property(self, property_name):
|
||||
plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
||||
if property_name in plist:
|
||||
return plist[property_name]
|
||||
if Path(self.global_settings_plist).exists():
|
||||
plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
||||
if property_name in plist:
|
||||
return plist[property_name]
|
||||
return None
|
||||
|
||||
def write_property(self, property_name, property_value):
|
||||
plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
||||
plist[property_name] = property_value
|
||||
plistlib.dump(plist, Path(self.global_settings_plist).open("wb"))
|
||||
if Path(self.global_settings_plist).exists():
|
||||
plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
||||
plist[property_name] = property_value
|
||||
plistlib.dump(plist, Path(self.global_settings_plist).open("wb"))
|
||||
|
||||
|
||||
def convert_defaults_to_global_settings(self):
|
||||
@@ -41,7 +43,11 @@ class global_settings:
|
||||
# merge defaults with global settings
|
||||
global_settings_plist = plistlib.load(Path(self.global_settings_plist).open("rb"))
|
||||
global_settings_plist.update(defaults_plist)
|
||||
plistlib.dump(global_settings_plist, Path(self.global_settings_plist).open("wb"))
|
||||
try:
|
||||
plistlib.dump(global_settings_plist, Path(self.global_settings_plist).open("wb"))
|
||||
except PermissionError:
|
||||
print("- Permission error: Unable to write to global settings file")
|
||||
return
|
||||
|
||||
# delete defaults plist
|
||||
Path(defaults_path).unlink()
|
||||
Reference in New Issue
Block a user