mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-09 13:52:00 -04:00
BIOSUtilities v24.10.01
Complete repository overhaul into python project Re-designed BIOSUtility base template class flow Re-structured utilities as BIOSUtility inherited Re-structured project for 3rd-party compatibility Unified project requirements and package version Code overhaul with type hints and linting support Switched external executable dependencies via PATH BIOSUtility enforces simple check and parse methods Utilities now work with both path and buffer inputs Adjusted class, method, function names and parameters Improved Dell PFS Update Extractor sub-PFAT processing Improved Award BIOS Module Extractor corruption handling Improved Apple EFI Image Identifier to expose the EFI ID Improved Insyde iFlash/iFdPacker Extractor with ISH & PDT Re-written Apple EFI Package Extractor to support all PKG
This commit is contained in:
parent
ef50b75ae1
commit
cda2fbd0b1
65 changed files with 6239 additions and 5233 deletions
94
biosutilities/common/externals.py
Normal file
94
biosutilities/common/externals.py
Normal file
|
@ -0,0 +1,94 @@
|
|||
#!/usr/bin/env python3 -B
|
||||
# coding=utf-8
|
||||
|
||||
"""
|
||||
Copyright (C) 2022-2024 Plato Mavropoulos
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from importlib.abc import Loader
|
||||
from importlib.machinery import ModuleSpec
|
||||
from importlib.util import module_from_spec, spec_from_file_location
|
||||
from types import ModuleType
|
||||
from typing import Type
|
||||
|
||||
|
||||
def big_script_tool() -> Type | None:
|
||||
""" Get Intel BIOS Guard Script Tool class """
|
||||
|
||||
bgst: str | None = shutil.which(cmd='big_script_tool')
|
||||
|
||||
if bgst and os.path.isfile(path=bgst):
|
||||
bgst_spec: ModuleSpec | None = spec_from_file_location(
|
||||
name='big_script_tool', location=re.sub(r'\.PY$', '.py', bgst))
|
||||
|
||||
if bgst_spec and isinstance(bgst_spec.loader, Loader):
|
||||
bgst_module: ModuleType | None = module_from_spec(spec=bgst_spec)
|
||||
|
||||
if bgst_module:
|
||||
sys.modules['big_script_tool'] = bgst_module
|
||||
|
||||
bgst_spec.loader.exec_module(module=bgst_module)
|
||||
|
||||
return getattr(bgst_module, 'BigScript')
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def comextract_path() -> str:
|
||||
""" Get ToshibaComExtractor path """
|
||||
|
||||
comextract: str | None = shutil.which(cmd='comextract')
|
||||
|
||||
if not (comextract and os.path.isfile(path=comextract)):
|
||||
raise OSError('comextract executable not found!')
|
||||
|
||||
return comextract
|
||||
|
||||
|
||||
def szip_path() -> str:
|
||||
""" Get 7-Zip path """
|
||||
|
||||
szip: str | None = shutil.which(cmd='7zzs') or shutil.which(cmd='7z')
|
||||
|
||||
if not (szip and os.path.isfile(path=szip)):
|
||||
raise OSError('7zzs or 7z executable not found!')
|
||||
|
||||
return szip
|
||||
|
||||
|
||||
def tiano_path() -> str:
|
||||
""" Get TianoCompress path """
|
||||
|
||||
tiano: str | None = shutil.which(cmd='TianoCompress')
|
||||
|
||||
if not (tiano and os.path.isfile(path=tiano)):
|
||||
raise OSError('TianoCompress executable not found!')
|
||||
|
||||
return tiano
|
||||
|
||||
|
||||
def uefifind_path() -> str:
|
||||
""" Get UEFIFind path """
|
||||
|
||||
uefifind: str | None = shutil.which(cmd='UEFIFind')
|
||||
|
||||
if not (uefifind and os.path.isfile(path=uefifind)):
|
||||
raise OSError('UEFIFind executable not found!')
|
||||
|
||||
return uefifind
|
||||
|
||||
|
||||
def uefiextract_path() -> str:
|
||||
""" Get UEFIExtract path """
|
||||
|
||||
uefiextract: str | None = shutil.which(cmd='UEFIExtract')
|
||||
|
||||
if not (uefiextract and os.path.isfile(path=uefiextract)):
|
||||
raise OSError('UEFIExtract executable not found!')
|
||||
|
||||
return uefiextract
|
Loading…
Add table
Add a link
Reference in a new issue