From a2f73a7bdcc220f9d2f2036d4c22903e4a844dff Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sun, 3 Oct 2021 14:10:56 -0600 Subject: [PATCH] Adjust Constants to python scheme --- .flake8 | 2 +- OpenCore-Patcher.command | 4 ++-- OpenCore-Patcher.spec | 4 ++-- create-offline-build.py | 4 ++-- merge_gui.py | 4 ++-- resources/Build.py | 4 ++-- resources/Utilities.py | 10 +++++----- resources/cli_menu.py | 4 ++-- resources/{Constants-tmp.py => constants.py} | 0 resources/sys_patch.py | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) rename resources/{Constants-tmp.py => constants.py} (100%) diff --git a/.flake8 b/.flake8 index 81016e515b..e9d577c621 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] extend-ignore = E501, E203 per-file-ignores = - Resources/Constants.py:E704 \ No newline at end of file + Resources/constants.py:E704 \ No newline at end of file diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index ecddb87037..cbf102178c 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -7,13 +7,13 @@ import subprocess import sys from pathlib import Path -from resources import Build, cli_menu, Constants, Utilities, device_probe, os_probe, defaults, arguments +from resources import Build, cli_menu, constants, Utilities, device_probe, os_probe, defaults, arguments from data import model_array class OpenCoreLegacyPatcher: def __init__(self): print("- Loading...") - self.constants = Constants.Constants() + self.constants = constants.Constants() self.generate_base_data() if arguments.arguments().check_cli() is False: self.main_menu() diff --git a/OpenCore-Patcher.spec b/OpenCore-Patcher.spec index 2a1f0e5eff..199793d77b 100644 --- a/OpenCore-Patcher.spec +++ b/OpenCore-Patcher.spec @@ -1,7 +1,7 @@ # -*- mode: python ; coding: utf-8 -*- import sys, os sys.path.append(os.path.abspath(os.getcwd())) -from resources import Constants +from resources import constants block_cipher = None @@ -38,7 +38,7 @@ app = BUNDLE(exe, icon="payloads/OC-Patcher.icns", bundle_identifier=None, info_plist={ - "CFBundleShortVersionString": Constants.Constants().patcher_version, + "CFBundleShortVersionString": constants.Constants().patcher_version, "CFBundleExecutable": "MacOS/Launcher", "NSHumanReadableCopyright": "Copyright 2020-2021 Dortania" }) \ No newline at end of file diff --git a/create-offline-build.py b/create-offline-build.py index 8da2e917bb..43059621e8 100644 --- a/create-offline-build.py +++ b/create-offline-build.py @@ -1,7 +1,7 @@ import subprocess -from resources import Constants +from resources import constants -patcher_support_pkg_version = Constants.Constants().patcher_support_pkg_version +patcher_support_pkg_version = constants.Constants().patcher_support_pkg_version binary_packages = ["10.14-Mojave", "10.15-Catalina", "11-Big-Sur", "12-Monterey"] for binary_package in binary_packages: diff --git a/merge_gui.py b/merge_gui.py index 0b2f74d2e6..86f3605af7 100644 --- a/merge_gui.py +++ b/merge_gui.py @@ -2,9 +2,9 @@ # Copyright (C) 2021 Mykola Grymalyuk import plistlib from pathlib import Path -from resources import Constants +from resources import constants app_path = Path.cwd() / Path ("OpenCore Patcher.app/Contents/Info.plist") info = plistlib.load(Path(app_path).open("rb")) -info["CFBundleShortVersionString"] = Constants.Constants().patcher_version +info["CFBundleShortVersionString"] = constants.Constants().patcher_version plistlib.dump(info, Path(app_path).open("wb"), sort_keys=True) \ No newline at end of file diff --git a/resources/Build.py b/resources/Build.py index 0a31383fce..5b73eef40d 100644 --- a/resources/Build.py +++ b/resources/Build.py @@ -14,7 +14,7 @@ from pathlib import Path from datetime import date -from resources import Constants, Utilities, device_probe, generate_smbios +from resources import constants, Utilities, device_probe, generate_smbios from data import smbios_data, bluetooth_data, cpu_data, os_data, model_array @@ -28,7 +28,7 @@ class BuildOpenCore: def __init__(self, model, versions): self.model = model self.config = None - self.constants: Constants.Constants = versions + self.constants: constants.Constants = versions self.computer = self.constants.computer self.gfx0_path = None diff --git a/resources/Utilities.py b/resources/Utilities.py index 6aec3590f2..75cb4e9350 100644 --- a/resources/Utilities.py +++ b/resources/Utilities.py @@ -20,7 +20,7 @@ except ImportError: raise Exception("Missing requests library!\nPlease run the following before starting OCLP:\npip3 install requests") -from resources import Constants, ioreg, device_probe +from resources import constants, ioreg from data import sip_data @@ -130,7 +130,7 @@ def amfi_status(): return True def check_kext_loaded(kext_name, os_version): - if os_version > Constants.Constants().catalina: + if os_version > constants.Constants().catalina: kext_loaded = subprocess.run(["kmutil", "showloaded", "--list-only", "--variant-suffix", "release"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) else: kext_loaded = subprocess.run(["kextstat", "-l"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -188,19 +188,19 @@ def patching_status(os_sip, os): gen6_kext = "/System/Library/Extension/AppleIntelHDGraphics.kext" gen7_kext = "/System/Library/Extension/AppleIntelHD3000Graphics.kext" - if os > Constants.Constants().catalina: + if os > constants.Constants().catalina: amfi_enabled = amfi_status() else: # Catalina and older supports individually disabling Library Validation amfi_enabled = False - if get_nvram("HardwareModel", "94B73556-2197-4702-82A8-3E1337DAFBFB", decode=False) not in Constants.Constants.sbm_values: + if get_nvram("HardwareModel", "94B73556-2197-4702-82A8-3E1337DAFBFB", decode=False) not in constants.Constants.sbm_values: sbm_enabled = False if get_nvram("csr-active-config", decode=False) and csr_decode(get_nvram("csr-active-config", decode=False), os_sip) is False: sip_enabled = False - if os > Constants.Constants().catalina and not check_filevault_skip(): + if os > constants.Constants().catalina and not check_filevault_skip(): # Assume non-OCLP Macs do not have our APFS seal patch fv_status: str = subprocess.run("fdesetup status".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() if "FileVault is Off" in fv_status: diff --git a/resources/cli_menu.py b/resources/cli_menu.py index 4c33886345..dff2138145 100644 --- a/resources/cli_menu.py +++ b/resources/cli_menu.py @@ -3,14 +3,14 @@ from __future__ import print_function import subprocess -from resources import Constants, Utilities, defaults, sys_patch +from resources import constants, Utilities, defaults, sys_patch from data import cpu_data, smbios_data, model_array class MenuOptions: def __init__(self, model, versions): self.model = model - self.constants: Constants.Constants = versions + self.constants: constants.Constants() = versions def change_verbose(self): Utilities.cls() diff --git a/resources/Constants-tmp.py b/resources/constants.py similarity index 100% rename from resources/Constants-tmp.py rename to resources/constants.py diff --git a/resources/sys_patch.py b/resources/sys_patch.py index 51f07c91e7..4d433bcaf8 100644 --- a/resources/sys_patch.py +++ b/resources/sys_patch.py @@ -11,14 +11,14 @@ import zipfile from pathlib import Path -from resources import Constants, device_probe, Utilities +from resources import constants, device_probe, Utilities from data import sip_data, sys_patch_data, model_array class PatchSysVolume: def __init__(self, model, versions): self.model = model - self.constants: Constants.Constants = versions + self.constants: constants.Constants() = versions self.computer = self.constants.computer self.root_mount_path = None self.sip_enabled = True