mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-12 22:26:13 -04:00
Added relevant exit codes at utilities
Fixed missing output path value crash Increased minimum Python version to 3.8
This commit is contained in:
parent
9b29c37c65
commit
cf88fc7a5d
6 changed files with 40 additions and 22 deletions
|
@ -7,7 +7,7 @@ AMI BIOS Guard Extractor
|
||||||
Copyright (C) 2018-2022 Plato Mavropoulos
|
Copyright (C) 2018-2022 Plato Mavropoulos
|
||||||
"""
|
"""
|
||||||
|
|
||||||
title = 'AMI BIOS Guard Extractor v4.0_a8'
|
TITLE = 'AMI BIOS Guard Extractor v4.0_a9'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -140,8 +140,8 @@ def get_ami_pfat(input_buffer):
|
||||||
|
|
||||||
return match, buffer
|
return match, buffer
|
||||||
|
|
||||||
def get_file_name(index, title):
|
def get_file_name(index, name):
|
||||||
return safe_name('%0.2d -- %s' % (index, title))
|
return safe_name('%0.2d -- %s' % (index, name))
|
||||||
|
|
||||||
def parse_bg_script(script_data, padding):
|
def parse_bg_script(script_data, padding):
|
||||||
is_opcode_div = len(script_data) % 8 == 0
|
is_opcode_div = len(script_data) % 8 == 0
|
||||||
|
@ -310,7 +310,7 @@ if __name__ == '__main__':
|
||||||
arguments = argparser.parse_args()
|
arguments = argparser.parse_args()
|
||||||
|
|
||||||
# Initialize script (must be after argparse)
|
# Initialize script (must be after argparse)
|
||||||
input_files,output_path,padding = script_init(title, arguments, 4)
|
exit_code,input_files,output_path,padding = script_init(TITLE, arguments, 4)
|
||||||
|
|
||||||
for input_file in input_files:
|
for input_file in input_files:
|
||||||
input_name = os.path.basename(input_file)
|
input_name = os.path.basename(input_file)
|
||||||
|
@ -330,4 +330,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
parse_pfat_file(pfat_buffer, extract_path, padding)
|
parse_pfat_file(pfat_buffer, extract_path, padding)
|
||||||
|
|
||||||
|
exit_code -= 1
|
||||||
|
|
||||||
printer('Done!', pause=True)
|
printer('Done!', pause=True)
|
||||||
|
|
||||||
|
sys.exit(exit_code)
|
||||||
|
|
|
@ -7,7 +7,7 @@ AMI UCP BIOS Extractor
|
||||||
Copyright (C) 2021-2022 Plato Mavropoulos
|
Copyright (C) 2021-2022 Plato Mavropoulos
|
||||||
"""
|
"""
|
||||||
|
|
||||||
title = 'AMI UCP BIOS Extractor v2.0_a10'
|
TITLE = 'AMI UCP BIOS Extractor v2.0_a11'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -500,7 +500,7 @@ if __name__ == '__main__':
|
||||||
is_checksum = arguments.checksum # Set Checksum verification optional argument
|
is_checksum = arguments.checksum # Set Checksum verification optional argument
|
||||||
|
|
||||||
# Initialize script (must be after argparse)
|
# Initialize script (must be after argparse)
|
||||||
input_files,output_path,padding = script_init(title, arguments, 4)
|
exit_code,input_files,output_path,padding = script_init(TITLE, arguments, 4)
|
||||||
|
|
||||||
for input_file in input_files:
|
for input_file in input_files:
|
||||||
input_name = os.path.basename(input_file)
|
input_name = os.path.basename(input_file)
|
||||||
|
@ -521,4 +521,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
ucp_extract(main_uaf_bin, extract_path, main_uaf_tag, padding, is_checksum)
|
ucp_extract(main_uaf_bin, extract_path, main_uaf_tag, padding, is_checksum)
|
||||||
|
|
||||||
|
exit_code -= 1
|
||||||
|
|
||||||
printer('Done!', pause=True)
|
printer('Done!', pause=True)
|
||||||
|
|
||||||
|
sys.exit(exit_code)
|
||||||
|
|
|
@ -7,7 +7,7 @@ Dell PFS Update Extractor
|
||||||
Copyright (C) 2018-2022 Plato Mavropoulos
|
Copyright (C) 2018-2022 Plato Mavropoulos
|
||||||
"""
|
"""
|
||||||
|
|
||||||
title = 'Dell PFS Update Extractor v6.0_a7'
|
TITLE = 'Dell PFS Update Extractor v6.0_a8'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import io
|
import io
|
||||||
|
@ -922,7 +922,7 @@ if __name__ == '__main__':
|
||||||
is_structure = arguments.structure # Set Structure output mode optional argument
|
is_structure = arguments.structure # Set Structure output mode optional argument
|
||||||
|
|
||||||
# Initialize script (must be after argparse)
|
# Initialize script (must be after argparse)
|
||||||
input_files,output_path,padding = script_init(title, arguments, 4)
|
exit_code,input_files,output_path,padding = script_init(TITLE, arguments, 4)
|
||||||
|
|
||||||
for input_file in input_files:
|
for input_file in input_files:
|
||||||
input_name = os.path.basename(input_file)
|
input_name = os.path.basename(input_file)
|
||||||
|
@ -966,4 +966,8 @@ if __name__ == '__main__':
|
||||||
# Call the PFS ZLIB Section Parser function
|
# Call the PFS ZLIB Section Parser function
|
||||||
pfs_section_parse(input_buffer, offset, extract_path, extract_name, 1, 1, False, padding, is_structure, is_advanced)
|
pfs_section_parse(input_buffer, offset, extract_path, extract_name, 1, 1, False, padding, is_structure, is_advanced)
|
||||||
|
|
||||||
|
exit_code -= 1
|
||||||
|
|
||||||
printer('Done!', pause=True)
|
printer('Done!', pause=True)
|
||||||
|
|
||||||
|
sys.exit(exit_code)
|
||||||
|
|
12
README.md
12
README.md
|
@ -31,7 +31,7 @@ You can either Drag & Drop or manually enter Dell PFS Update images(s). Optional
|
||||||
|
|
||||||
#### **Compatibility**
|
#### **Compatibility**
|
||||||
|
|
||||||
Should work at all Windows, Linux or macOS operating systems which have Python 3.7 support.
|
Should work at all Windows, Linux or macOS operating systems which have Python 3.8 support.
|
||||||
|
|
||||||
#### **Prerequisites**
|
#### **Prerequisites**
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ Optionally, to decompile the Intel BIOS Guard (PFAT) Scripts, you must have the
|
||||||
|
|
||||||
PyInstaller can build/freeze/compile the utility at all three supported platforms, it is simple to run and gets updated often.
|
PyInstaller can build/freeze/compile the utility at all three supported platforms, it is simple to run and gets updated often.
|
||||||
|
|
||||||
1. Make sure Python 3.7.0 or newer is installed:
|
1. Make sure Python 3.8.0 or newer is installed:
|
||||||
|
|
||||||
> python --version
|
> python --version
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ You can either Drag & Drop or manually enter AMI UCP BIOS executable file(s). Op
|
||||||
|
|
||||||
#### **Compatibility**
|
#### **Compatibility**
|
||||||
|
|
||||||
Should work at all Windows, Linux or macOS operating systems which have Python 3.7 support.
|
Should work at all Windows, Linux or macOS operating systems which have Python 3.8 support.
|
||||||
|
|
||||||
#### **Prerequisites**
|
#### **Prerequisites**
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ Optionally, to decompile the AMI UCP \> AMI PFAT \> Intel BIOS Guard Scripts (wh
|
||||||
|
|
||||||
PyInstaller can build/freeze/compile the utility at all three supported platforms, it is simple to run and gets updated often.
|
PyInstaller can build/freeze/compile the utility at all three supported platforms, it is simple to run and gets updated often.
|
||||||
|
|
||||||
1. Make sure Python 3.7.0 or newer is installed:
|
1. Make sure Python 3.8.0 or newer is installed:
|
||||||
|
|
||||||
> python --version
|
> python --version
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ You can either Drag & Drop or manually enter AMI BIOS Guard (PFAT) image file(s)
|
||||||
|
|
||||||
#### **Compatibility**
|
#### **Compatibility**
|
||||||
|
|
||||||
Should work at all Windows, Linux or macOS operating systems which have Python 3.7 support.
|
Should work at all Windows, Linux or macOS operating systems which have Python 3.8 support.
|
||||||
|
|
||||||
#### **Prerequisites**
|
#### **Prerequisites**
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ Optionally, to decompile the AMI PFAT \> Intel BIOS Guard Scripts, you must have
|
||||||
|
|
||||||
PyInstaller can build/freeze/compile the utility at all three supported platforms, it is simple to run and gets updated often.
|
PyInstaller can build/freeze/compile the utility at all three supported platforms, it is simple to run and gets updated often.
|
||||||
|
|
||||||
1. Make sure Python 3.7.0 or newer is installed:
|
1. Make sure Python 3.8.0 or newer is installed:
|
||||||
|
|
||||||
> python --version
|
> python --version
|
||||||
|
|
||||||
|
|
|
@ -132,8 +132,11 @@ def process_input_files(argparse_args, sys_argv=None):
|
||||||
else:
|
else:
|
||||||
input_files = [file.name for file in argparse_args.files]
|
input_files = [file.name for file in argparse_args.files]
|
||||||
|
|
||||||
# Set output path via argparse Output Path or argparse Input Path or first input file Path
|
# Set output fallback value for missing argparse Output and Input Path
|
||||||
output_path = argparse_args.output_dir or argparse_args.input_dir or path_parent(input_files[0])
|
output_fallback = path_parent(input_files[0]) if input_files else None
|
||||||
|
|
||||||
|
# Set output path via argparse Output path or argparse Input path or first input file path
|
||||||
|
output_path = argparse_args.output_dir or argparse_args.input_dir or output_fallback
|
||||||
else:
|
else:
|
||||||
# Script w/o parameters
|
# Script w/o parameters
|
||||||
input_path_user = get_dequoted_path(input('\nEnter input directory path: '))
|
input_path_user = get_dequoted_path(input('\nEnter input directory path: '))
|
||||||
|
|
|
@ -34,14 +34,14 @@ def is_auto_exit():
|
||||||
def check_sys_py():
|
def check_sys_py():
|
||||||
sys_py = get_py_ver()
|
sys_py = get_py_ver()
|
||||||
|
|
||||||
if sys_py < (3,7):
|
if sys_py < (3,8):
|
||||||
sys.stdout.write('\nError: Python >= 3.7 required, not %d.%d!' % (sys_py[0], sys_py[1]))
|
sys.stdout.write('\nError: Python >= 3.8 required, not %d.%d!' % (sys_py[0], sys_py[1]))
|
||||||
|
|
||||||
if not is_auto_exit():
|
if not is_auto_exit():
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
(raw_input if sys_py[0] <= 2 else input)('\nPress enter to exit') # pylint: disable=E0602
|
(raw_input if sys_py[0] <= 2 else input)('\nPress enter to exit') # pylint: disable=E0602
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(125)
|
||||||
|
|
||||||
# Check OS Platform
|
# Check OS Platform
|
||||||
def check_sys_os():
|
def check_sys_os():
|
||||||
|
@ -53,7 +53,7 @@ def check_sys_os():
|
||||||
if not is_auto_exit():
|
if not is_auto_exit():
|
||||||
input('\nPress enter to exit')
|
input('\nPress enter to exit')
|
||||||
|
|
||||||
sys.exit(2)
|
sys.exit(126)
|
||||||
|
|
||||||
# Fix Windows Unicode console redirection
|
# Fix Windows Unicode console redirection
|
||||||
if os_win: sys.stdout.reconfigure(encoding='utf-8')
|
if os_win: sys.stdout.reconfigure(encoding='utf-8')
|
||||||
|
@ -93,7 +93,10 @@ def script_init(title, arguments, padding=0):
|
||||||
# Process input files and generate output path
|
# Process input files and generate output path
|
||||||
input_files,output_path = process_input_files(arguments, sys.argv)
|
input_files,output_path = process_input_files(arguments, sys.argv)
|
||||||
|
|
||||||
return input_files, output_path, padding
|
# Count input files for exit code
|
||||||
|
input_count = len(input_files)
|
||||||
|
|
||||||
|
return input_count, input_files, output_path, padding
|
||||||
|
|
||||||
# https://stackoverflow.com/a/781074 by Torsten Marek
|
# https://stackoverflow.com/a/781074 by Torsten Marek
|
||||||
def nice_exc_handler(exc_type, exc_value, tb):
|
def nice_exc_handler(exc_type, exc_value, tb):
|
||||||
|
@ -107,7 +110,7 @@ def nice_exc_handler(exc_type, exc_value, tb):
|
||||||
if not is_auto_exit():
|
if not is_auto_exit():
|
||||||
input('\nPress enter to exit')
|
input('\nPress enter to exit')
|
||||||
|
|
||||||
sys.exit(3)
|
sys.exit(127)
|
||||||
|
|
||||||
# Show message(s) while controlling padding, newline, pausing & separator
|
# Show message(s) while controlling padding, newline, pausing & separator
|
||||||
def printer(in_message='', padd_count=0, new_line=True, pause=False, sep_char=' '):
|
def printer(in_message='', padd_count=0, new_line=True, pause=False, sep_char=' '):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue