mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-22 19:25:21 -04:00
Added Award BIOS Module Extractor v2.0_a3
Improved 7-Zip exit code handling
This commit is contained in:
parent
fc73921967
commit
82cd4336bd
7 changed files with 184 additions and 13 deletions
|
@ -18,10 +18,17 @@ def get_szip_path():
|
|||
|
||||
return safe_path(project_root(), ['external',exec_name])
|
||||
|
||||
# Check 7-Zip bad exit codes (0 OK, 1 Warning)
|
||||
def check_bad_exit_code(exit_code):
|
||||
if exit_code not in (0,1):
|
||||
raise Exception(f'BAD_EXIT_CODE_{exit_code}')
|
||||
|
||||
# Check if file is 7-Zip supported
|
||||
def is_szip_supported(in_path, padding=0, silent=False):
|
||||
def is_szip_supported(in_path, padding=0, check=False, silent=False):
|
||||
try:
|
||||
subprocess.run([get_szip_path(), 't', in_path, '-bso0', '-bse0', '-bsp0'], check=True)
|
||||
szip_t = subprocess.run([get_szip_path(), 't', in_path, '-bso0', '-bse0', '-bsp0'], check=False)
|
||||
|
||||
if check: check_bad_exit_code(szip_t.returncode)
|
||||
except:
|
||||
if not silent:
|
||||
printer(f'Error: 7-Zip could not check support for file {in_path}!', padding)
|
||||
|
@ -31,11 +38,13 @@ def is_szip_supported(in_path, padding=0, silent=False):
|
|||
return True
|
||||
|
||||
# Archive decompression via 7-Zip
|
||||
def szip_decompress(in_path, out_path, in_name, padding=0, silent=False):
|
||||
def szip_decompress(in_path, out_path, in_name, padding=0, check=False, silent=False):
|
||||
if not in_name: in_name = 'archive'
|
||||
|
||||
try:
|
||||
subprocess.run([get_szip_path(), 'x', '-aou', '-bso0', '-bse0', '-bsp0', '-o' + out_path, in_path], check=True)
|
||||
szip_x = subprocess.run([get_szip_path(), 'x', '-aou', '-bso0', '-bse0', '-bsp0', '-o' + out_path, in_path], check=False)
|
||||
|
||||
if check: check_bad_exit_code(szip_x.returncode)
|
||||
|
||||
if not os.path.isdir(out_path): raise Exception('EXTRACT_DIR_MISSING')
|
||||
except:
|
||||
|
|
|
@ -9,6 +9,7 @@ import re
|
|||
|
||||
PAT_AMI_PFAT = re.compile(br'_AMIPFAT.AMI_BIOS_GUARD_FLASH_CONFIGURATIONS', re.DOTALL)
|
||||
PAT_AMI_UCP = re.compile(br'@(UAF|HPU).{12}@', re.DOTALL)
|
||||
PAT_AWARD_LZH = re.compile(br'-lh[04567]-')
|
||||
PAT_DELL_FTR = re.compile(br'\xEE\xAA\xEE\x8F\x49\x1B\xE8\xAE\x14\x37\x90')
|
||||
PAT_DELL_HDR = re.compile(br'\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51.\x78\x9C', re.DOTALL)
|
||||
PAT_DELL_PKG = re.compile(br'\x72\x13\x55\x00.{45}7zXZ', re.DOTALL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue